In a Kotlin Multiproject setup we have gradle/jacoco/sonarqube working fine.
However, I tried to exclude some projects as they contain only generated code and started by excluding them from jacoco by configuring:
jacocoTestReport {
dependsOn test
reports {
xml.required = true
csv.required = false
html.required = true
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
"de/exclude/example/"
"**/de/*"
])
}))
}
}
Which leads to Jacoco xml and html files containing no further info.
But in Sonarqube it showed 0.0% and was still counted in to my overall test coverage.
I then found that I can exclude code for sonar by adding:
sonar {
properties {
property "sonar.coverage.exclusions", "src/main/**"
}
}
to the build.gradle
files.
I’ve read through some articles here to find if this is intended behaviour but could not really find out.
So mabye someone here can answer this?
Shouldn’t empty (i.e. only xml header but no content for classes) jacoco xml files lead to excluded coverage info in Sonarqube? Just like it does when I use sonar.coverage.exclusions
?