Maven - Jacoco Configuration

Maven Jacoco Configuration

In order to get jacoco report for a project, set up this plugin in pom.xml

 <plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.8.8</version>
    <executions>
        <execution>
            <id>jacoco-report</id>
            <goals>
                <goal>report</goal>
            </goals>
        </execution>
    </executions>
</plugin>

This will make sure that the maven build will include a jacoco report in the target folder.

Exclude classes/packages from report not working

In order to exclude certain classes, packages, etc. from the jacoco report, set up exclusions in the plugin like this.

 <plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.8.8</version>
    <configuration>
        <excludes>
            <exclude>**/*Config.*</exclude>
            <exclude>**/*Dev.*</exclude>
        </excludes>
    </configuration>
    <executions>
        <execution>
            <id>jacoco-report</id>
            <goals>
                <goal>report</goal>
            </goals>
        </execution>
    </executions>
</plugin>

External references

https://www.eclemma.org/jacoco/trunk/doc/report-mojo.html


Links to this note