I’m facing an issue with code coverage reporting in a multi-module Maven project. Here are the details:
Project details:
-
Multi-module Maven project
-
Using JaCoCo Maven plugin version
0.8.10 -
SonarQube version:v26.2.0.119303
-
Gradle projects with the same setup work fine, but Maven projects don’t show coverage
What I did:
-
Configured JaCoCo Maven plugin to generate
jacoco.xmlreport:<plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.8.10</version> <executions> <execution> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>report</id> <phase>verify</phase> <goals> <goal>report</goal> </goals> </execution> </executions></plugin>
This text will be hidden
Configured SonarQube to pick up the report:
<sonar.coverage.jacoco.xmlReportPaths>
module/target/site/jacoco-aggregate/jacoco.xml
</sonar.coverage.jacoco.xmlReportPaths>
- Ran
mvn clean verify sonar:sonar
Problem:
-
On the first scan, the coverage is not visible in SonarQube.
-
If I rerun the scan, it shows 0% coverage.
-
The logs show:
No coverage report can be found with sonar.coverage.jacoco.xmlReportPaths -
The same setup works fine for Gradle projects.
What I’ve tried:
-
Verified the
jacoco.xmlis actually generated at the path specified -
Used both relative and absolute paths in
sonar.coverage.jacoco.xmlReportPaths -
Checked plugin version compatibility with SonarQube