Reputation: 641
I have a basic maven multi-module, with a parent being the POM and three children modules : domain, service and web.
I have added in the pom parent the jacoco plugin and the required configuration to append the test coverage report to a single file easily located by sonar.
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.2.201302030002</version>
<configuration>
<destFile>${project.basedir}/../target/jacoco.exec</destFile>
<append>true</append>
</configuration>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
My issue is that Sonar shows only the test coverage of the first module (being domain) (even though I open the file with an editor and I see the class names of the others modules being append in it.
What could wrong in this configuration ?
For what it's worth, sonar analysis is called from Jenkins, and not from mvn sonar:sonar
Upvotes: 0
Views: 4574
Reputation: 641
Jenkins configuration is the key : There is no need to append everything in a single file when the configuration is right.
I added this to the config :
sonar.modules=xxx-domain,xxx-service,xxx-web
and I deleted the configuration tag in the pom.xml given in the question.
It works like a charm
For those who struggle with this, look for anything useful to specify the jenkins project configuration for sonar
Upvotes: 1
Reputation: 26843
You can check our sample application here: https://github.com/SonarSource/sonar-examples/tree/master/projects/code-coverage/ut/maven/ut-maven-jacoco-runTests
You should be able to find what's wrong with your configuration then.
Upvotes: 0