How exclude class from jacoco maven reporting

1,901 views
Skip to first unread message

glor...@gmail.com

unread,
Nov 18, 2016, 1:38:14 AM11/18/16
to JaCoCo and EclEmma Users
Hello,
I am trying to exclude a java class from reporting of the maven jacoco plugin. But I do not manage.

I see the coverage is 0% after the exclusion but the class is still in the report html page. Is it possible to remove it from the html report ?

Evgeny Mandrikov

unread,
Nov 18, 2016, 5:02:35 AM11/18/16
to JaCoCo and EclEmma Users, glor...@gmail.com
Hi,

Exclusions from instrumentation ( http://www.eclemma.org/jacoco/trunk/doc/instrument-mojo.html#excludes ) is not the same as exclusion from report generation ( http://www.eclemma.org/jacoco/trunk/doc/report-mojo.html#excludes ) - we also have following ticket about inconsistency https://github.com/jacoco/jacoco/issues/34#issuecomment-10205525

In attachment you'll find an example of how to exclude file from report.
jacoco-example.zip

glor...@gmail.com

unread,
Nov 18, 2016, 5:55:10 AM11/18/16
to JaCoCo and EclEmma Users, glor...@gmail.com
I have tried to use yout example

with some change in the pom file to see the reporting
but when I do mvn clean package site I have still the class B in the reporting ... xwhat can I do ?


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>example</artifactId>
<version>0.1-SNAPSHOT</version>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.7.201606060606</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>
<configuration>
<excludes>
<exclude>org/example/B.class</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<reporting>
<plugins>

<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.8</version>
<configuration>
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
</configuration>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<!-- select non-aggregate reports -->
<report>report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>


</project>


Evgeny Mandrikov

unread,
Nov 18, 2016, 6:38:51 AM11/18/16
to JaCoCo and EclEmma Users, glor...@gmail.com
My example creates report with excluded file not as part of site generation ("mvn clean package").
As far as I remember - plugins declared in "reporting" section for site generation have completely separate configuration and you don't configure exclusions here.

Evgeny Mandrikov

unread,
Nov 18, 2016, 6:42:59 AM11/18/16
to JaCoCo and EclEmma Users, glor...@gmail.com
Quoting https://maven.apache.org/pom.html#Reporting : "build plugin configuration does not affect a reporting plugin"
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages