Hi I am trying to exclude classes for my code coverage using jacoco. I want to exclude the gui folder and all the classes inside it.
I have also faced the same problem.In my case ,I was trying to generate code coverage of a application which was running on j2EE server. I have tried to remove some classes which were not getting used much , to increase code coverage, but exclude does not worked for me.
At last i have tried work around for this instead of using exclude in to configuration. I have removed the clasess from the path of the task that was responsible for generating report.
Maven include/exclude syntax is Ant. So I suggest you to have a look on fileset documentation, where you can find few illustrative examples.
In your particular configuration, it could work this pattern
**/gui/**
assuming that you don't use the package name "gui" in other context.
We can exclude the class from coverage checking (i.e. fail the build if the coverage doesn't meet the target), but not exclude them from the reporting (i.e. you can still see the class in the report). Is it what you after?
If you would like to exclude the classes from checking, you could try the following config, and please use com.project.folder.tools.gui.* pattern without the slash and trailing suffix.
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<haltOnFailure>true</haltOnFailure>
<rules>
<rule>
<element>CLASS</element>
<excludes>
<exclude>com.example.className</exclude>
<exclude>com.example.config.*</exclude>
</excludes>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.80</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
Check this offical doco for detail