Template for a good bug report, formatted with Markdown:
versions used (SonarQube, Scanner, Plugin, and any relevant extension)
Apache Maven 3.5.4
Java version: 1.8.0_144
Sonar Version 8.4.1
Jacoco maven plugin 0.8.5
Jacoco sonar plugin 1.1.0.898
error observed (wrap logs/code around triple quote ``` for proper formatting)
The coverage is displayed as 0% in sonar.
steps to reproduce
I build a eclipse application with tycho. It’s a multi module application.
I have unit tests on specific modules (ask by tycho)
I have a coverage report module with a xml report generated and not empty and a html report with the good value
Sonar parse it:
INFO] Sensor JaCoCo XML Report Importer [jacoco]
[INFO] Importing 1 report(s). Turn your logs in debug mode in order to see the exhaustive list.
[INFO] Sensor JaCoCo XML Report Importer [jacoco] (done) | time=70ms
I check in debug mode and the report is the good one.
So my conclusion is it’s due to inclusions/exclusions. but i put empty element in my parent pom and nothing is change.
Any idea?
<sonar.inclusions>
**/*
</sonar.inclusions>
<sonar.exclusions>
</sonar.exclusions>
<!-- Code coverage by unit tests -->
<sonar.coverage.exclusions>
</sonar.coverage.exclusions>
Just to add more information.
The build have note the same parent for build and for unit test and sonar build.
product
- coverage.parent
- coverage report
- child1
- child1.test
- child2
- child3
- child3.test
I do:
mvn clean install -f product/pom.xml
then
mvn clean verify -f product/coverage.parent/pom.xml
then
mvn sonar:sonar -f product/coverage.parent/pom.xml
Starting with your first post, you really don’t need to specify exclusions/inclusions for most Maven projects. I would strip those properties out of the pom IIWY.
You haven’t actually specified your version of SonarQube. That would be helpful.
Also, it would be helpful to post your code-formatted (``` on the line before and on the line after) analysis logs.
Sorry it’s my sonar qube version. I don’t fix my sonar maven plugin.
With my path:
i have the log: [INFO] 19:14:41.732 Coverage report '/home/builder/jenkins_workspace/....coverage.report/target/site/jacoco-aggregate/jacoco.xml' could not locate source file MiscCachedInformation.java in package my/package/model.
So the locator don’t find the file according to this line:
I appreciate your willingness to contribute a PR. Unfortunately, even if it’s accepted, the next release isn’t expected until the end of Sept. (early Oct. if I’m being realistic).
sorry for the delay but i try many fix and debug the sensor. It seem to be due because of our folder structure. The jacoco sensor plugin don’t find the source file.
I find a reproducer (i simply fork an existing repo and step by step go to our structure):
I do to commit. One to reach a case where sonar fill the coverage.
mvn clean install -Pjacoco
mvn sonar:sonar -Dsonar.coverage.jacoco.xmlReportPaths=$PWD/example.tests.report/target/site/jacoco-aggregate/jacoco.xml
And it’s works! But…
I do another commit which change the structure and the command line to reach my real project structure :
mvn clean install -f releng/coverage.parent/pom.xml -Pjacoco
mvn sonar:sonar -f releng/coverage.parent/pom.xml -Dsonar.coverage.jacoco.xmlReportPaths=$PWD/example.tests.report/target/site/jacoco-aggregate/jacoco.xml
I try with sonar 8.4.2 on my laptop:
In both case the jacoco report (xml and html) is well (with a coverage).
But sonar don’t detect it and display a 0% coverage in the second case and seems to not find any source code.
For information it works if we go from root:
mvn sonar:sonar -Dsonar.coverage.jacoco.xmlReportPaths=$PWD/example.tests.report/target/site/jacoco-aggregate/jacoco.xml
Based on this, I found a way to pass throught the bug. Instead of using a sub project as root module for coverage. I use a pom_coverage.xml in the root directory. And it’s works perfectly.