Using:
- sonar-maven-plugin (scanner) 3.7.0.1746
- SonarCloud.io with same results on Docker image sonarqube:latest
Error:
- Code coverage is mistakenly reported as 0%.
- Error message in Maven build is: “[WARNING] No coverage report can be found with sonar.coverage.jacoco.xmlReportPaths=’/Users/desharpe/dev/weblogic-image-tool/installer/imagetool/target/site/jacoco/jacoco.xml’. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml”
Searching the community here, I see very similar posts, all of them appear unresolved, or “it must be your settings” sorts of answers. Having the same (or at least similar issue), I tried and tried various combinations of settings, values, etc. The result seems to show that the sonarsource scanner plugin or the scanner itself is interpreting the value from the pom incorrectly.
With this value (or a whole host of other attempted values) for xmlReportPaths:
<sonar.coverage.jacoco.xmlReportPaths>${basedir}/imagetool/target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
mvn sonar:sonar
Running maven with this produces the error (above) with 0% coverage reported. But by adding the -D with the same value, the warning never shows in the log, and the code coverage is reported correctly.
mvn sonar:sonar -Dsonar.coverage.jacoco.xmlReportPaths=/Users/desharpe/dev/weblogic-image-tool/imagetool/target/site/jacoco/jacoco.xml
The workaround is simple, set Sonar scanner options on the command line, and do not bother with setting them in the POM file. Is this an issue with the Sonar scanner, scanner plugin, or are we doing something wrong in our configuration?