Using:
- SonarQube Community Edition v. 7.9.1
- sonar-maven-plugin v. 3.6.0.1398
- jacoco-maven-plugin v. 0.8.4
I'm trying to upload the JaCoCo coverage report from my java maven project. I followed the instructions presented in this link and this example.
I used the following profile configuration:
<profiles>
<profile>
<id>coverage</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
For performing the scan I'm running:
mvn clean verify sonar:sonar
And I'm getting this log:
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ componente-procesos ---
[INFO] Building jar: C:\Users\Usuario\Documents\NetBeansProjects\componente-procesos\target\componente-procesos-1.0.10.jar
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.4:report (report) @ componente-procesos ---
[INFO] Loading execution data file C:\Users\Usuario\Documents\NetBeansProjects\componente-procesos\target\jacoco.exec
[INFO] Analyzed bundle 'componente-procesos' with 14 classes
[INFO]
[INFO] ----------< com.framework:componente-procesos >----------
[INFO] Building componente-procesos 1.0.10
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:3.6.0.1398:sonar (default-cli) @ componente-procesos ---
[INFO] User cache: C:\Users\Usuario\.sonar\cache
[INFO] SonarQube version: 7.9.1
[INFO] Default locale: "es_CO", source code encoding: "UTF-8"
[WARNING] SonarScanner will require Java 11+ to run starting in SonarQube 8.x
[INFO] Load global settings
[INFO] Load global settings (done) | time=728ms
[INFO] Server id: 02F7F878-AW5hfQnpp0zDeLaf_V6M
[INFO] User cache: C:\Users\Usuario\.sonar\cache
[INFO] Load/download plugins
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=502ms
[INFO] Load/download plugins (done) | time=699ms
[INFO] Process project properties
[INFO] Execute project builders
[INFO] Execute project builders (done) | time=2ms
[INFO] Project key: com.framework:componente-procesos
[INFO] Base dir: C:\Users\Usuario\Documents\NetBeansProjects\componente-procesos
[INFO] Working dir: C:\Users\Usuario\Documents\NetBeansProjects\componente-procesos\target\sonar
[INFO] Load project settings for component key: 'com.framework:componente-procesos'
[INFO] Load project settings for component key: 'com.framework:componente-procesos' (done) | time=507ms
[INFO] Load quality profiles
[INFO] Load quality profiles (done) | time=528ms
[INFO] Load active rules
[INFO] Load active rules (done) | time=2224ms
[INFO] Indexing files...
[INFO] Project configuration:
[INFO] 34 files indexed
[INFO] 0 files ignored because of scm ignore settings
[INFO] Quality profile for java: Sonar way
[INFO] ------------- Run sensors on module componente-procesos
[INFO] Load metrics repository
[INFO] Load metrics repository (done) | time=445ms
[INFO] Sensor JavaSquidSensor [java]
[INFO] Configured Java source version (sonar.java.source): 8
[INFO] JavaClasspath initialization
[INFO] JavaClasspath initialization (done) | time=57ms
[INFO] JavaTestClasspath initialization
[INFO] JavaTestClasspath initialization (done) | time=21ms
[INFO] Java Main Files AST scan
[INFO] 19 source files to be analyzed
[INFO] Load project repositories
[INFO] Load project repositories (done) | time=451ms
[INFO] 19/19 source files have been analyzed
[INFO] Java Main Files AST scan (done) | time=6152ms
[INFO] Java Test Files AST scan
[INFO] 7 source files to be analyzed
[INFO] Java Test Files AST scan (done) | time=947ms
[INFO] 7/7 source files have been analyzed
[INFO] Sensor JavaSquidSensor [java] (done) | time=8676ms
[INFO] Sensor FindBugs Sensor [findbugs]
[INFO] Sensor FindBugs Sensor [findbugs] (done) | time=7ms
[INFO] Sensor SurefireSensor [java]
[INFO] parsing [C:\Users\Usuario\Documents\NetBeansProjects\componente-procesos\target\surefire-reports]
[INFO] Sensor SurefireSensor [java] (done) | time=270ms
[INFO] Sensor JavaXmlSensor [java]
[INFO] 7 source files to be analyzed
[INFO] Sensor JavaXmlSensor [java] (done) | time=436ms
[INFO] 7/7 source files have been analyzed
[INFO] ------------- Run sensors on project
[INFO] Sensor Zero Coverage Sensor
[INFO] Sensor Zero Coverage Sensor (done) | time=87ms
[INFO] Sensor Java CPD Block Indexer
[INFO] Sensor Java CPD Block Indexer (done) | time=67ms
[INFO] 10 files had no CPD blocks
[INFO] Calculating CPD for 9 files
[INFO] CPD calculation finished
[INFO] Analysis report generated in 355ms, dir size=163 KB
[INFO] Analysis report compressed in 218ms, zip size=74 KB
[INFO] Analysis report uploaded in 483ms
[INFO] ANALYSIS SUCCESSFUL, you can browse http://localhost?id=com.framework%3Acomponente-procesos
[INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[INFO] More about the report processing at http://localhost/api/ce/task?id=AXCq9AfxRuQxKd0pV_VN
[INFO] Analysis total time: 17.061 s
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 54.203 s
[INFO] Finished at: 2020-03-05T08:48:05-05:00
[INFO] ------------------------------------------------------------------------
As you can see, I'm not getting the expected logs from Sensor JaCoCo XML Report Importer.
And even though the jacoco.xml is being generated with the correct coverage results, this result is not being uploaded to sonar, the analysis throws 0% coverage result.
Can you help me to show the coverage results in sonar analysis?
Please let me know if I can provide more information in order to understand better the problem.