Java coverage @ 0.0% with JacocoXMLReport

We are attempting to run sonar-scanner v4.0.0.1744 to parse our Gradle generated Jacoco coverage xml report. We have tried to upload our java coverage reports with sonar-scanner in two different ways:

  • Using sonar.jacoco.reportPaths – This worked for us and we see coverage results on Sonarqube, but required us to set the, sonar.test.binaries options to point to the appropriate Java build directories. Our only issue with using “reportPaths” is that it is deprecated, so we want to switch to using the sonar.coverage.jacoco.xmlReportPaths option instead.
  • Using sonar.coverage.jacoco.xmlReportPaths – This does not work for us. We point it to the xml report path and we set all the same flags as the one above except for the sonar.jacoco.reportPaths .

We were targeting pushing results to Sonarqube Developer Edition v7.3. To make sure it was not a bug with the webapp/deployment, we stood up another separate temporary deployment of Sonarqube Community Edition v7.9.2 LTS server, and attempted to push the results there with the same version of sonarqube scanner with the same two methods above; we still get 0.0% coverage with the sonar.coverage.jacoco.xmlReportPaths option.

Is there a bug with scanner, or are we doing something wrong when invoking scanner?

Thank you!

Hi Devin,

Could you share your versions of the following plugins on each of your SonarQube servers (in SonarQube / Administration / Marketplace):

  • SonarJava, Code Analyzer for Java (e.g. 6.2)
  • JaCoCo, JaCoCo XML report importer (e.g. 1.0.3)

Because before SonarJava 5.12, it was SonarJava that was responsible for importing JaCoCo binary format report (build/jacoco/test.exec) through the property sonar.jacoco.reportPaths.
And now, it’s recommended to use the JaCoCo XML report importer plugin that imports the XML format report (build/reports/jacoco/test/jacocoTestReport.xml) through the property sonar.coverage.jacoco.xmlReportPaths.

So depending on your plugin versions, the import property could be different.
You should also run the analysis in debug mode to be able to see what is imported, e.g.:

[INFO] 16:59:10.201 Sensor JaCoCo XML Report Importer [jacoco]
[INFO] 16:59:10.201 1/1 source files have been analyzed
[DEBUG] 16:59:10.203 Reading report '/home/user/project/build/reports/jacoco/test/jacocoTestReport.xml'
[INFO] 16:59:10.208 Sensor JaCoCo XML Report Importer [jacoco] (done) | time=7ms

See: [Coverage & Test Data] Importing JaCoCo coverage report in XML format