SonarQube 8.1, sonar-maven-plugin 3.7.0.1746, jacoco-maven-plugin 0.8.5
At our company we all use the sonar.jacoco.reportPath property and it works great. We let all the maven modules write to a single exec file with the property “append=true”. The maven sonar plugin reports all coverage.
It’s currently impossible to switch to sonar.coverage.jacoco.xmlReportPaths, without doing major changes to all the projects.
As an example, take the setup of 3 maven modules M1, M2, M3. Where M1 is a dependency of M2 and M2 is a dependency of M3.
As we write to 1 exec file for all modules, running sonar:sonar takes all tests into accounts when analysing M1, M2 and M3.
But for the jacoco reports, it’s not possible todo this. The report step of jacoco will already run when M1 is building, and at this stage the tests in M2 and M3 have not. The coverage is incorrect.
Jacoco’s solution is to create a report project and use the report-aggregate. https://github.com/jacoco/jacoco/tree/master/jacoco-maven-plugin.test/it/it-report-aggregate
This is not feasable for all our old projects. We dont want to create a seperate maven module for every tool that is around that we use. This solution is too intrusive on the structure of the project.
Another solution that I tried is to use the report and the report-aggregate goal for all projects. There are in total 6 reports, 2 for each module. And the sum of reports is correct. BUT when running sonar:sonar, sonar analyses M1 and takes only the 2 reports of his module into account, and not the aggregate reports of M2 and M3.
Jacoco could also offer a merge-report step. Or could offer to write to a single location with an “append=true” like the binary format. But they unfortunately do not. Reports are generated seperately and writing to a single location just overwrites the reports. The jacoco-maven-plugin only has a merge goal for exec files, not for report files.
I know the jacoco guys could do something different to allow a full xml report. But they dont.
Sonar tries to push projects to use the xmlReportPaths, but that is just not feasible for multi module maven projects which have tests that cover classes in multiple projects. The needed configuration is very error prone and not ok for big organisations.
The binary jacoco format works out of the box, is dummy proof and easy to configure.
If sonar decides to drop the support of the binary format, we have a problem. I read in forums that this is your plan. Can you please keep supporting it or provide an alternative where the xml reports are as easy to use?