1
votes

I have a Maven multiproject build. The unit tests are using PowerMock 1.6.6, and I've managed to generate individual Jacoco (0.7.8) exec files for each module using the "offline" process. I also have a single module that uses the "report-aggregate" to generate a single JaCoCo report.

I'm now trying to integrate with SonarQube 5.6.5, using sonar-scanner 2.8.

Using this doc page I naturally constructed a command line setting the "sonar.jacoco.reportPaths" property to a comma-separated list of paths to the "jacoco.exec" file in each child module. This appeared to have no effect. I saw a message in the output saying "INFO: JaCoCoSensor: JaCoCo report not found : <mycurrentdirectory>\target\jacoco.exec".

So, I instead set property "sonar.jacoco.reportPath" to the same comma-separated value. This at least had an effect, but it confused the scanner, as it obviously expected this to be a single location.

I then tried setting that property to just the first of the several "jacoco.exec" files. That at least completed, but with minimal coverage data.

How do I proceed? Am I instead supposed to somehow use the Jacoco "merge" goal to merge all of my jacoco.exec files into a single file, and specify that, or is there a different undocumented property that allows a list of paths to files?

1
JaCoCo reports should be found (in the normal location) automatically. What happens when you remove the setting?G. Ann - SonarSource Team
This is a multiproject build with many child projects. There is no "normal location" for it to find these data files in. As the "reportPaths" property is obviously ignored, I'm now trying to use the Jacoco "merge" goal to produce a single file, as the "reportPath" property appears to be recognized.David M. Karr
What version of SonarJava are you using?G. Ann - SonarSource Team
I'm told we have version 4.4.0.8066 installed.David M. Karr
Looking at the latest source (github.com/SonarSource/sonar-java/tree/master/java-jacoco/src/…), it does appear to check for "sonar.jacoco.reportPaths", but it doesn't seem like that works in the version I have.David M. Karr

1 Answers

0
votes

I verified that the advertised "sonar.jacoco.reportPaths" property only works in SonarQube versions 6.2 or newer (the docs have apparently been updated to reflect this).

Therefore, I moved forward with implementing "merge", specifying the filesets for all the modules. It took a while to get the data correct for that fileset list (Maven, like many frameworks, often says nothing when your configuration data represents files or components that don't exist).