Unable to see code coverage in multi-module Maven project with JaCoCo 0.8.10

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:

  1. Configured JaCoCo Maven plugin to generate jacoco.xml report:

    <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>
  1. 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.xml is actually generated at the path specified

  • Used both relative and absolute paths in sonar.coverage.jacoco.xmlReportPaths

  • Checked plugin version compatibility with SonarQube

Hi,

Could you add -X to your analysis command line to enable debug logging, and post the log? Off-hand, it looks like the report isn’t being found by analysis.

This this configured at the module level or in the top pom.xml?

 
Ann

This configuration is from the main pom.xml. I tried specifying the jacoco.xml report path directly in the command, and it worked. However, the coverage seems to vary each time. The coverage shown in SonarQube appears to be line coverage, not method coverage, as far as I can tell. Also, the coverage is currently displayed only in the Overall section and not in the New Code section.

Hi,

You’re saying 2 runs with no changes get 2 different sets of coverage numbers?

It’s not quite as simple as that. Condition coverage is factored into the percentage number. There’s detail in the docs.

 
HTH,
Ann

Yes, the two runs show different coverage percentages.

Hi,

Can I have screenshots and the analysis logs from both runs?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Thx,
Ann