Issue while generating SonarQube (8.9) report in multi-maven project

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?

Hi Doyal, welcome to the SonarSource Community!

We have an example multi-module maven project in our scanning examples repo. You probably won’t be thrilled to see that it also hinges on using the report-aggregate goal. I’m not aware of another solution for a multi-module maven repo.

Thanks, @Jeff_Zapotoczny for getting back on this. You are right, I am not thrilled :frowning:
However, I will stay in touch in case I require any further information on the same.

Thanks again :slight_smile: