Reputation: 91
After upgrading Java from 8 to 11. sonar:sonar is not working getting exception in the end.
Java 1.8 is working fine with Sonarqube 7.7, now with java 11 and sonarqube 7.8 it is failing with exception
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar (default-cli) on project xxxx: Unable to read ....\target\jacoco.exec to determine JaCoCo binary format.: EOFException -> [Help 1]
Using below properties for java 11
<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
<sonar.sources>src/main</sonar.sources>
<sonar.tests>src/test</sonar.tests>
<runSuite>**/*Test.class</runSuite>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis
<sonar.jacoco.reportPaths>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPaths>
<sonar.language>java</sonar.language>
Below plugins using jacoco
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>${java.version}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<argLine>--illegal-access=permit</argLine>
<includes>
<include>${runSuite}</include>
</includes>
<forkCount>0</forkCount>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.4</version>
<configuration>
<destFile>${sonar.jacoco.reportPaths}</destFile>
<append>true</append>
</configuration>
<executions>
<execution>
<id>agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
Am I missing any configuration in pom file to run sonarqube using jacoco
Upvotes: 2
Views: 13325
Reputation: 1
This is a known issue, since maven-surefire-plugin
version 3.0.0-M3
this is fixed. I had the same issue and the migrating from version 2.22.2
to 3.1.2
fixed it.
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
</dependency>
Source: maven-surefire-plugin change log
P.S.: Don't forget to update the maven-failsafe-plugin
as well, if you are using it.
Upvotes: 0
Reputation: 91
Removing sonar.coverage.jacoco.xmlReportPaths
and maven-surefire-plugin
gave the code coverage. Issue is fixed.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<argLine>--illegal-access=permit</argLine>
<includes>
<include>${runSuite}</include>
</includes>
<forkCount>0</forkCount>
</configuration>
</plugin>
Useful links:
https://52.213.100.93/browse/MMF-1651
https://github.com/SonarSource/sonar-scanning-examples/tree/master/sonarqube-scanner-maven
Upvotes: 3
Reputation: 91
The issue was with property need to include sonar.coverage.jacoco.xmlReportPaths
<sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/../target/jacoco.exec</sonar.coverage.jacoco.xmlReportPaths>
After changing the mvn sonar:sonar is successful but the code coverage is 0%
Upvotes: 1