Current versions where issue is being faced: SonarQube 8.9, jacoco-maven-plugin 0.8.5
Through earlier version of jacoco-maven-plugin - 7.9, multiple maven modules used write to a single exec file for both unit and integration test cases. This was achievable through the property “append=true”. The coverage got mapped to Sonar properly.
jacoco-maven-plugin (8.5) on the other hand does not have a merge goal for xml files and we are unable to generate a single file to feed into the new Sonar version expecting .xml files only. So it is currently impossible to switch to sonar.coverage.jacoco.xmlReportPaths for multi module projects.
I have seen Jacoco’s solution asking us to create a report project/module and use the report-aggregate. This is not feasible for our projects. We do not want to create a separate maven module for every tool that we use. This solution is unacceptable w.r.t our project structure.
The solution that we tried was to use the report and the report-aggregate goal for all projects (parent and child) as per : [Coverage & Test Data] Importing JaCoCo coverage report in XML format
However, the reports are generated separately at child level.
We tried to provide the path of the generated xmls in our build script, but it showed the below error:
15:43:13 INFO: Coverage report doesn’t exist for pattern: ‘****M1//target/site/jacoco/jacoco.xml’ (M1 being one service)
15:43:13 INFO: Coverage report doesn’t exist for pattern: ‘****M2/target/site/jacoco/jacoco.xml’ (M2 being another service)
15:43:13 WARN: No coverage report can be found with sonar.coverage.jacoco.xmlReportPaths=’****M1/target/site/jacoco/jacoco.xml,****M2/target/site/jacoco/jacoco.xml
Please note : The index.html files generated at the above locations do show the coverage though but it is not getting pulled into Sonar.
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. We have not been able to achieve the result with the recommended configurations.
Could you please confirm how to configure our multi module projects so that sonar picks up the coverage report?