ALM & CI system: Azure DevOps
Scanner: SonarQube plugin version “4.4.1.3373”
Hi, when i run the Sonar scanner as part of my gradle multi-project build, the analysis only covers the files of the root folder, but not of the subprojects.
BUT, when i instead use the dedicated SonarCloudAnalyze task and let it run immediately after the gradle build task, all subprojects are analyzed. Why does it behave differently?
Here is my sonar config from build.gradle.kts:
plugins {
...
id("org.sonarqube") version "4.4.1.3373"
}
sonar {
properties {
property("sonar.projectKey", "...")
property("sonar.projectName", "...")
}
}
subprojects {
...
apply(plugin = "org.sonarqube")
sonar {
properties {
property("sonar.language", "java")
property("sonar.inclusions", "**/*.java")
property("sonar.sourceEncoding", "UTF-8")
if (file("src/main/java").exists()) {
property("sonar.sources", "src/main/java")
property("sonar.java.binaries", "${buildDir}/classes/java/main")
}
}
}
}
And of course in the settings.gradle, all subprojects are included.
Here is the config of the SonarCloudPrepare task when i used the scanner as part of gradle build:
steps:
- task: SonarCloudPrepare@1
inputs:
SonarCloud: '...'
organization: '...'
scannerMode: 'Other'
extraProperties: |
# Additional properties that will be passed to the scanner,
# Put one key=value per line, example:
sonar.projectKey=...
sonar.projectName=...
sonar.verbose=true
And this is the config of the SonarCloudPrepare task when i used the dedicated scanner of SonarCloudAnalyze task:
steps:
- task: SonarCloudPrepare@1
inputs:
SonarCloud: '...'
organization: '...'
scannerMode: 'CLI'
configMode: 'manual'
cliProjectKey: '...'
cliProjectName: '...'
extraProperties: |
# Additional properties that will be passed to the scanner,
# Put one key=value per line, example:
sonar.java.binaries=$(System.DefaultWorkingDirectory)/**/target/classes/java/main
sonar.inclusions=**/*.java
sonar.verbose=true
I have seen other users mentioning the same issue with a gradle multi-project build, but unfortunately the solution was not posted in the thread, like here: