Skip to content

Jacoco Maven plugin to fill the gap of the official one that doesn't ease submodules code coverage

License

Notifications You must be signed in to change notification settings

codefilarete/jacoco-aggregate-submodule

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

JaCoCo Java Code Coverage Library reviewed for Maven multi-module aggregation

Why

As discussed here, creating an aggregation of Jacoco reports can be painful when dealing with a multi-modules Maven project, since it requires to create a module dedicated to it and add reported modules as a dependency of it. Although a proposition was made, it is not in Jacoco Team roadmap. So this project is made to fix it.

How to use

Replace your jacoco-maven-plugin report-aggregate execution...

<executions>
    <execution>
        <id>report-aggregate</id>
        <goals>
            <goal>report-aggregate</goal>
        </goals>
        <phase>verify</phase>
    </execution>
</executions>

... by the one of this project

<plugin>
    <groupId>org.codefilarete</groupId>
    <artifactId>jacoco-aggregate-submodule</artifactId>
    <version>${codefilarete.jacoco.version}</version>
    <executions>
        <execution>
            <id>report-aggregate</id>
            <goals>
                <goal>report-aggregate</goal>
            </goals>
            <phase>verify</phase>
        </execution>
    </executions>
</plugin>

This module doesn't handle all features made by Jacoco plugin : it handles only aggregation for submodules so you have to keep all other goals you have in your pom.xml which may finally look like :

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>${jacoco.version}</version>
    <executions>
        <execution>
            <id>prepare-agent</id>
            <goals>
                <goal>prepare-agent</goal>
            </goals>
        </execution>
        <execution>
            <id>report</id>
            <goals>
                <goal>report</goal>
            </goals>
        </execution>
        <!-- the following is replaced by Codefilarete plugin below -->
        <!--<execution>-->
        <!--<id>report-aggregate</id>-->
        <!--<goals>-->
        <!--<goal>report-aggregate</goal>-->
        <!--</goals>-->
        <!--<phase>verify</phase>-->
        <!--</execution>-->
    </executions>
</plugin>
<plugin>
    <groupId>org.codefilarete</groupId>
    <artifactId>jacoco-aggregate-submodule</artifactId>
    <version>${codefilarete.jacoco.version}</version>
    <executions>
        <execution>
            <id>report-aggregate</id>
            <goals>
                <goal>report-aggregate</goal>
            </goals>
            <phase>verify</phase>
        </execution>
    </executions>
</plugin>

Disclaimer

  • I didn't find out how final aggregated report was saved, I've just kept original Mojo philosophy and ... it works ! see ReportAggregateMojo.java
  • There are no tests for this plugin since it's a hard work
  • It is build with Java 8. Hope it will work with all superior version.

Reference

About

Jacoco Maven plugin to fill the gap of the official one that doesn't ease submodules code coverage

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages