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
This commit is contained in:
11
build.gradle
11
build.gradle
@@ -321,23 +321,22 @@ configure(javaProjects) { subproject ->
|
||||
compileKotlin.dependsOn updateCopyrights
|
||||
|
||||
jacocoTestReport {
|
||||
onlyIf { System.properties['sonar.host.url'] }
|
||||
dependsOn test
|
||||
reports {
|
||||
csv.required = false
|
||||
xml.required = true
|
||||
html.required = false
|
||||
xml.outputLocation = file("${buildDir}/reports/jacoco/test/jacocoTestReport.xml")
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.tasks['sonarqube'].dependsOn jacocoTestReport
|
||||
|
||||
test {
|
||||
maxHeapSize = '2g'
|
||||
jvmArgs '-XX:+HeapDumpOnOutOfMemoryError'
|
||||
jacoco {
|
||||
destinationFile = file("$buildDir/jacoco.exec")
|
||||
}
|
||||
|
||||
if (System.properties['sonar.host.url']) {
|
||||
finalizedBy jacocoTestReport
|
||||
}
|
||||
}
|
||||
|
||||
task testAll(type: Test, dependsOn: [':checkAsciidocLinks', 'check'])
|
||||
|
||||
Reference in New Issue
Block a user