Hi!
We are using Jacoco’s aggregated report for a Maven multi-module project as described in Java test coverage | SonarQube Server Documentation, also including the “…/” fix for the sonar.coverage.jacoco.xmlReportPaths
property that we found in other topics in this community.
The root pom.xml
contains these:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>${sonar.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
and this:
<properties>
<jacoco.plugin.version>0.8.12</jacoco.plugin.version>
<sonar.plugin.version>5.0.0.4389</sonar.plugin.version>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.organization>myproject-dev</sonar.organization>
<sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/../aggregate-coverage-report/target/site/jacoco-aggregate/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
</properties>
And the module with the report contains this:
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>report-aggregate</id>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Using mvn clean verify
I can confirm that the report is generated just fine and the coverage is about 56%.
When I ran mvn sonar:sonar
, I can see that the report is being picked up:
sonar_scanner.log (44.1 KB)
However, in sonarcloud.io, I see that the coverage is 0.0%:
What am I missing?
Thank you in advance!