user2000223
user2000223

Reputation: 81

How to merge 2 jacoco coverage reports (.exec file) irrespective of maven life cycle

I have a jacoco plugin in my pom to get junit test coverage and I am dumping another report from a different server. How to merge these 2 jacoco coverage reports (.exec file) irrespective of maven life cycle.

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.7.6.201602180812</version>
    <executions>
      <execution>
        <goals>
          <goal>prepare-agent</goal>
        </goals>
        <configuration>
          <destFile>${project.build.directory}</destFile>
        </configuration>     
      </execution>
    </executions>        
</plugin>

Upvotes: 5

Views: 8065

Answers (1)

spi
spi

Reputation: 1735

You could use the goal "merge", binding it with the phase of your choice: http://www.eclemma.org/jacoco/trunk/doc/merge-mojo.html

Maybe with a config like:

<plugin>
    <artifactId>jacoco-maven-plugin</artifactId>
    <executions>
        ...
        <execution>
            <id>merge-all-jacoco</id>
            <goals><goal>merge</goal></goals>
            <phase>install</phase>
            <configuration> 
              <destFile>merged.exec</destFile> 
              <fileSets>
                <fileSet>
                  <directory>${project.build.directory}</directory>
                  <includes>
                    <include>*.exec</include>
                  </includes>
                </fileSet>
              </fileSets>
            </configuration> 
        </execution>
    </executions>
</plugin>

Upvotes: 1

Related Questions