0
votes

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

2
Why do you add jacoco-maven-plugin to your POM? Sonar does not require any additional plugins. It works fine with existing POMs without any modificationsZhekaKozlov
@orionll I add the plugin and especially for the configuration in order to append the jacoco.exec files of each in module into a single one in the parent forlder.Julien BRENELIERE

2 Answers

1
votes

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

0
votes