Tech Stack:
- JDK 17;
- Spring Boot 2.6.6
- Maven 3.8.5
- Gitlab Enterprise Edition 14.10.0-ee
My Java project is using multiple modules, I followed this guide here.
You can see here how my project is organized:
Into the main pom.xml file I added it:
<build>
<plugins>
<plugin>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
<groupId>org.jacoco</groupId>
<version>0.8.8</version>
</plugin>
</plugins>
</build>
In the report module I added it:
<build>
<plugins>
<plugin>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>report-aggregate</goal>
</goals>
<id>report-aggregate</id>
<phase>verify</phase>
</execution>
</executions>
<groupId>org.jacoco</groupId>
<version>0.8.8</version>
</plugin>
</plugins>
</build>
The report module has the responsibility to aggregate the report just this.
When I ran ./mvnw clean verify
and check under the report/target/site/jacoco-aggregate
folder, I am able to check the correct report for the 3 modules:
In the main pom.xml file I added this property:
<sonar.coverage.jacoco.xmlReportPaths>
${project.basedir}/../report/target/site/jacoco-aggregate/jacoco.xml,
${project.basedir}/report/target/site/jacoco-aggregate/jacoco.xml
</sonar.coverage.jacoco.xmlReportPaths>
But when I ran the pipeline into Gitlab and when I check it into SonarQube, I can see the coverage only for one module (data module):
I already checked the Gitlab log and I saw that Jacoco plugin was able to find the report;
[INFO] Sensor JaCoCo XML Report Importer [jacoco]
[INFO] Importing 1 report(s). Turn your logs in debug mode in order to see the exhaustive list.
[INFO] Sensor JaCoCo XML Report Importer [jacoco] (done) | time=59ms
Do I miss some configuration to be able to reach my goal to see the coverage for all modules?