Hi all,
We have Sonar enterprise version installed in our company. We have been playing with a simple multi module java project and obtained an aggregate jacoco.xml report which contains all the coverage view in the project. The problem is that SonarQube is unable to display it in the GUI (it’s all the time 0 coevarge)
The skeleton of the project looks like this
parent pom.xml
... contains ...
<modules>
<module>processing</module>
<module>reports</module>
<module>aggregator</module>
</modules>
...
<profile>
<id>integration</id>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.1.2</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>**/*IT.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
two submodules:
report and processing which contains BOTH
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<configuration>
<!-- Rest of your configuration, if any -->
<formats>XML</formats>
</configuration>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
and an aggregator submodule like:
contains the dependencies for both sub modules: report and processing
<dependencies>
<dependency>
<groupId>com.mercuria.multiprj</groupId>
<artifactId>reports</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.mercuria.multiprj</groupId>
<artifactId>processing</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
and
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
<configuration>
<dataFileIncludes>
<dataFileInclude>**/jacoco.exec</dataFileInclude>
</dataFileIncludes>
<outputDirectory>
${project.reporting.outputDirectory}/jacoco-aggregate
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
The jacoco.xml file looks pretty good, also we obtained the html report which is browsable and contains accurate report, but somehow the sonarqube is not able to interpret it.
We use a stage in gitlab with sonar-scanner and i’m able to see
this:
07:30:42.768 DEBUG: Reading report ‘/builds/development/finance/sandbox/giant-multimodules/target/site/jacoco-aggregate/jacoco.xml’
Hi Ann,
Thank you for your fast response, and sorry for my late response ( i was in a short holiday all these days). As I mentioned the report is generated locally, is also loaded by sonarQube, but nothing appear.
In the code above listed, I added also the aggregator report, and is almost the same as it is in the docs:
Now , maybe the problem is in the following gitlab steps listed below. I’m doing a hack, somehow on the app build step i generate the reports in the aggregator submodule and copied into a folder called artifacts (which is preserved during stages) and on the sonar-check step I copied the content of it, back to target folder of the root project.
Thanks for sharing this. Can you double-check that the file paths in the report match the file paths analysis is seeing? This (admitted) hack makes me wonder if pathing isn’t the problem.
Thanks for the sample project. I’m not a Mavenista, so there are some things I’m not sure about, but you say you’re getting the report (locally) that you expect. So we’ll set those aside.
Going back to this:
You move the aggregated report file around before anlaysis and in the end, put it in the project root target directory.
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.
Hi,
Well we have a problem and we were forced to use sonnar scanner
( which is basically the same as being invoked from maven sonar plugin) because the initial java multi module project is written in an old java 8 and latest sonarqube maven plugin cannot be invoked for java 8. But it should be perfect fine, the same sonar scanner command is used for other different java single module projects(in company) and is working fine. So it should be ok.
Hi,
Well the problem is that everything is dockerize and we don’t have an image with two java versions. However i’ve uploaded the content of the aggregated report (jacoco.xml) and it looks good IMO. jacoco.zip (1.1 KB)
So you’re running the SonarScanner CLI with Java 8? That means it’s pretty out of date at this point. You need to figure out how to run a current, supported scanner version, and it might as well be the SonarScanner for Maven.
Hi,
We are pulling sonarcli from https://hub.docker.com/r/sonarsource/sonar-scanner-cli (which contains SONAR_SCANNER_VERSION=5.0.1.3006 and java 17) and we just ran it as:
sonar-scanner -Droject.settpings=./sonar-project.properties
Basically we give the location of the jacoco.xml from the aggregated report
The content of sonar-project.properties is: