I have a multimodule project with a parent pom.xml and two modules in it. Project.jar and Project.war. All the test cases are under Project.jar. When I run mvn sonar.sonar goal on the Parent pom, jacoco.exec is not getting generated and code coverage is blank. I have the following properties in the parent pom.
<properties>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.jacoco.reportPath>${project.basedir}/target/jacoco.exec</sonar.jacoco.reportPath>
</properties>
Please help. I am using Sonarqube 4.2.
For those that have a similar issue, I solved this problem slightly differently (where I'm running it from the command-line and not having Jenkins do it). I didn't have an issue with the plugins.
All these settings are defined in the parent POM. I am using the following version:
The report path is slightly different, this makes it so only one jacoco.exec is created. By default Sonar will append results together if the file already exists.
In the pluginManagement section, I have the following plugin:
Then in my plugins section I make sure the plugin is available for the entire project:
As benzonico noted, you need to run tests prior to sonar analyzing them, which I do as follows:
I did not have to make any changes to the Surefire plugin (as I've had to do in the past).
With version 2.4 of the java plugin you have to generate the coverage report before running the SonarQube analysis. You can see this page http://docs.codehaus.org/display/SONAR/JaCoCo+Plugin about how to do this.