No Coverage in Multi-module Maven Build with Jacoco

Hello all,

I am running into issues when trying to enable scanning on a multi-module maven project wrapped inside a parent autoconfigure. Although coverage shows up in the individual test project target/site/jacoco directories, this coverage is not maintained in the target/site/jacoco-aggregate directories so is not being picked up by a sonar scan.

Our setup:

  • sonar-maven-plugin:3.7.0.1746
  • jacoco:0.8.5

Project Structure:

Screen Shot 2021-05-19 at 1.40.40 PM

Here, the spring-boot/2.0.5 and spring-boot/2.4.0 directories each contain modules with tests on the code within the spring-boot/src directory.

Following the guide to implement jacoco xml scanning, we have included the following in our pom files:

spring-boot/pom.xml:

<properties>
    <aggregate.report.dir>target/site/jacoco-aggregate/jacoco.xml</aggregate.report.dir>
</properties>
<build>
    <plugins>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>report</id>
                    <goals>
                        <goal>report-aggregate</goal>
                    </goals>
                    <phase>verify</phase>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

spring-boot/2.0.5/pom.xml and spring-boot/2.4.0/pom.xml:

<properties>
    <sonar.coverage.jacoco.xmlReportPaths>${basedir}/../${aggregate.report.dir}</sonar.coverage.jacoco.xmlReportPaths>
</properties>

Both of the generated jacoco-aggregate reports are then picked up by the scanner, but neither are showing the test coverage that is present in the base jacoco reports.

Does anyone have a sense as to why this may be occuring?

1 Like