Jacoco Excludes Configuration not working

Skip to first unread message

Momina Babar

Apr 4, 2024, 4:02:42 PMApr 4
to JaCoCo and EclEmma Users
Hi All,

I am trying to use the jacoco exclude filter to filter out Controllers and DTO classes from coverage report. All controllers have the file format: *Controller.java and all dto files *Dto.java so I want to exculde on the basis of that. 

This is what I have in pom.xml: 

<plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.8.12</version> <configuration> <excludes> <exclude>com/example/mw/**/*Controller.java</exclude> <exclude>com/example/mw/**/*Dto.java</exclude> </excludes> </configuration> <executions> <execution> <id>prepare-agent</id> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>report</id> <phase>install</phase> <goals> <goal>report</goal> </goals> </execution> <execution> <id>jacoco-check</id> <phase>install</phase> <goals> <goal>check</goal> </goals> <configuration> <target> <propertyfile file="lombok.config"> <entry key="config.stopBubbling" value="true"/> <entry key="lombok.addLombokGeneratedAnnotation" value="true"/> </propertyfile> </target> <rules> <rule> <element>BUNDLE</element> <limits> <limit> <counter>LINE</counter> <value>COVEREDRATIO</value> <minimum>0.61</minimum> </limit> </limits> </rule> </rules> </configuration> </execution> </executions> </plugin>

I have tried various combinations trying complete wildcard configurations but nothing works these classes still show up in coverage report. Only manually adding @Generated annotation works but I want to do it so that all controllers and dtos get handled automatically.

Please let me know what am I doing wrong. I have tried all online solutions. I am using java 17 with spring boot 3.x. 

P.S. I have tried clean build, rebuild many times to no avail only Generated makes  difference. I tried to add annotation of Generated on compile to every class but it only adds that to constructor not the entire class so not useful either. 

Marc Hoffmann

Apr 5, 2024, 7:47:05 AMApr 5
to JaCoCo and EclEmma Users

the excludes patterns refer to class file names, not sources. Please try



You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/26cde6ec-34eb-4062-a16c-bac0c62da734n%40googlegroups.com.

Reply all
Reply to author
0 new messages