Q: Why does Clover instrument classes I have excluded using the <exclude>
element of the
<clover-setup>
task?There are two possible causes:
- Cascading build files:
Clover uses Ant patternsets to manage the includes and excludes specified in the<clover-setup>task. By default Ant does not pass these patternsets to the sub-builds. If you are using
a master-build/sub-build arrangement, with compilation occuring in the sub-builds and<clover-setup>done in the master-build, you will need to explicitly pass these patternsets as references:<ant ...> <reference refid="clover.files"/> <reference refid="clover.useclass.files"/> </ant> - Excluded files are still registered in the Clover database:
Clover's database is built incrementally, and this can mean that files that are now excluded but were previously included are still reported on. The simple workaround is to delete the Clover database whenever you change the Clover includes or excludes. - You are trying to exclude a method using a method context filter:
ThemethodContextfilter does not prevent instrumentation. It only marks matching methods in the Clover database, so that they can be filtered out of a report later on. See Excluding methods below.
Excluding whole Maven modules
In order to disable Clover entirely for a given module, use the <skip>
configuration parameter or the maven.clover.skip user property:
<configuration>
<skip>true</skip>
</configuration>
mvn ... -Dmaven.clover.skip=true
Excluding files in Maven
Use the <excludes> parameter:
<configuration>
<excludes>
<exclude>**/*Dull.java</exclude>
</excludes>
</configuration>
See Configuring instrumentation for more details.
Excluding methods
Neither file exclusion patterns nor methodContexts can stop Clover from instrumenting
an individual method. The only way to prevent instrumentation of a piece of code is to use inline
source directives:
// CLOVER:OFF
... code which must not be instrumented ...
// CLOVER:ON
The scope of these directives is the current file only, and they are not supported in Groovy. This is typically needed for code processed by bytecode-manipulating frameworks - see Using Source Directives and Does Clover work with AspectJ?.