Hi all,
I’m struggling pretty hard setting up the test coverage in Sonarqube with gradle. I’m using
- SonarQube: 7.9.3 (build 33349)
- Code Analyzer for Java version 6.3.2 (build 22818)
- JaCoCo XML report importer 1.1.0 (build 898)
- Gradle Plugin in version 3.0
Sonarqube shows me all the time 0% code coverage:
But if i check the jacoco report it’s definitely not 0

My build.gradle (I tried to keep only the relevant parts):
buildscript {
//...
}
plugins {
id 'java'
id 'org.sonarqube' version '3.0'
id 'jacoco'
}
sourceCompatibility = '11'
targetCompatibility = '11'
dependencies {
//...
}
test {
finalizedBy jacocoTestReport
testLogging {
outputs.upToDateWhen { false }
showStandardStreams = true
exceptionFormat = 'full'
}
}
sonarqube {
properties {
property 'sonar.projectKey', 'NAME'
property 'sonar.host.url', 'https://sonarqube....'
property 'sonar.projectVersion', project.version
property 'sonar.language', 'java'
property 'sonar.core.codeCoveragePlugin', 'jacoco'
property 'sonar.jacoco.reportPaths', "${buildDir}/jacoco/test.exec"
property 'sonar.coverage.jacoco.xmlReportPaths', "${buildDir}/reports/jacoco/jacoco.xml"
}
}
tasks['sonarqube'].dependsOn test
jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
xml.destination file("${buildDir}/reports/jacoco/jacoco.xml")
}
}
The location of the exec file is build/jacoco/test.exec and the xml file in build/reports/jacoco/jacoco.xml
I expect that something is wrong with the expected sonar properties or missing a plugin. But tried such a lot of combinations and I checked the documentation and other articles yesterday for couple of hours and was not able to find the issue.
Thanks for your help! Appreciated.