-1

I do searched for similar topics. But mine issue is different. The background is that I've got an single spring boot project, and it became bigger and bigger. Then I split it into serveral modules following the guide from spring Spring boot - Creating a Multi Module Project.

Let's say, now I've got 2 projects: Web and ServiceLayer. All my previous integration test are in Web now, and it looks like that from sonar I can only see the coverage of proejct-web.

I am using jacoco maven plugin and here is the maven pom:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <version>2.19.1</version>
            <configuration>
                <showSuccess>false</showSuccess>
            </configuration>
        </plugin>

        <!-- JaCoCo configuration -->
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.7.5.201505241946</version>
            <executions>
                <execution>
                    <id>default-prepare-agent</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>default-report</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

How to configure and make the coverage of submodules available on sonar? Thanks!

Joe
  • 91
  • 1
  • 5
  • Possible duplicate of [How to configure multi-module Maven + Sonar + JaCoCo to give merged coverage report?](http://stackoverflow.com/questions/13031219/how-to-configure-multi-module-maven-sonar-jacoco-to-give-merged-coverage-rep) – philip Mar 27 '17 at 12:21

1 Answers1

0

You can add the destFile tag after your goals tag

Something like this

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.7.8</version>
    <configuration>
        <append>true</append>
    </configuration>
    <executions>
        <execution>
            <id>default-prepare-agent</id>
            <goals>
                <goal>prepare-agent</goal>
            </goals>
            <configuration>
                 <destFile>${project.basedir}/../target/jacoco.exec</destFile>
            </configuration>
        </execution>
        <execution>
            <id>default-report</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>report</goal>
            </goals>
        </execution>
    </executions>
</plugin>

This will aggregrate all the results in each of the modules into a file.

philip
  • 484
  • 9
  • 26