Reputation: 51
I am working with Liferay DXP and I would like integrate SonarQube in my workspace, I am using gradle.
My workspace is called: test-workpace
My gradle.properies file (path: test-workspace/gradle.properties) is:
systemProp.sonar.host.url=http://localhost:9000
systemProp.sonar.sourceEncoding=UTF-8
systemProp.sonar.forceAuthentication=true
systemProp.sonar.login=<mytoken>
# Definición de variables para el proyecto.
description = 'Gradle - Sample Project'
group = 'com.test.sonarqube.gradle'
version = '1.0.0'
My build.gradle file (path: test-workspace/build.gradle) is:
buildscript {
repositories {
mavenLocal()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath group: "org.sonarsource.scanner.gradle", name:"sonarqube-gradle-plugin", version:"2.5"
}
}
group = 'com.test.sonarqube.gradle'
apply plugin: "org.sonarqube"
When I execute "gradle sonarqube" all workspace is scanned but I would like to configure each modules like a project in SonarQube.
Someone know how to configure gradle files to do it?.
Thank you very much!
Upvotes: 2
Views: 12624
Reputation: 2771
As Olaf points out: This question was also posted to https://web.liferay.com/community/forums/-/message_boards/message/104477676
You could configure all the subprojects as a different SonarQube project with the following in your build.gradle
:
subprojects{
sonarqube {
properties {
property 'sonar.projectName', "${-> project.name}"
}
}
}
You can also set the property sonar.projectKey
or any other property from https://docs.sonarqube.org/display/SONAR/Analysis+Parameters
I took the idea of the lazily evaluated project name from: How can I make Gradle extensions lazily evaluate properties that are set dynamically by tasks?
Upvotes: 0