Skip to content

Commit db90e68

Browse files
committed
Fix Sonar and JaCoCo relationship
* Explicitly enable Jacoco XML report Must be `xml.required = true` * Starting with version 3 the Sonarqube Gradle plugin does not do any automatic dependencies on other tasks: https://docs.sonarqube.org/latest/analyzing-source-code/scanners/sonarscanner-for-gradle/ * It is also does not apply the task to sub-projects. So, to make the root `sonarqube` task we need to have config like this: ``` rootProject.tasks['sonarqube'].dependsOn jacocoTestReport ``` Note: the `sonarqube` task is deprecated in favor of `sonar`, but that is exactly what our current Bamboo Sonar plugin does. So, when that is upgraded, we need to revise our config again * We don't need `xml.outputLocation` since its default is what Sonar expects
1 parent 8b99178 commit db90e68

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

build.gradle

+5-6
Original file line numberDiff line numberDiff line change
@@ -321,23 +321,22 @@ configure(javaProjects) { subproject ->
321321
compileKotlin.dependsOn updateCopyrights
322322

323323
jacocoTestReport {
324+
onlyIf { System.properties['sonar.host.url'] }
325+
dependsOn test
324326
reports {
325-
csv.required = false
327+
xml.required = true
326328
html.required = false
327-
xml.outputLocation = file("${buildDir}/reports/jacoco/test/jacocoTestReport.xml")
328329
}
329330
}
330331

332+
rootProject.tasks['sonarqube'].dependsOn jacocoTestReport
333+
331334
test {
332335
maxHeapSize = '2g'
333336
jvmArgs '-XX:+HeapDumpOnOutOfMemoryError'
334337
jacoco {
335338
destinationFile = file("$buildDir/jacoco.exec")
336339
}
337-
338-
if (System.properties['sonar.host.url']) {
339-
finalizedBy jacocoTestReport
340-
}
341340
}
342341

343342
task testAll(type: Test, dependsOn: [':checkAsciidocLinks', 'check'])

0 commit comments

Comments
 (0)