Java – Configuring clover exclude file patterns



I have clover 3.0 setup using ant, with the following file exclusions:

<clover-setup initString="${clover.initstring}" flushpolicy="threaded" flushinterval="30000">
    <methodContext name="tostring" regexp="(.* )?public String toString\(.*\).*" />
        <exclude name="**/*" />
        <exclude name="**/entity/fields/*.java" />

The *Test files are excluded correctly, as is the toString() calls, the files under the entity/fields package are not. Does the <files> ant type work with two excludes items? Can you have a partial package definition on your exclude name? I used **/..... format as the doc says something cryptic like

An Ant patternset, relative to the top level package (e.g. com/cenqua/clovertest), element which controls which files are included or excluded from Clover instrumentation. Use this when you wish to exclude files based on packages.

From this I read it starts at clovertest in the sample, although i'm not sure how it knows what the top level package is? Is that the first package with files?

As an example my java classes that i want to exclude are like

package com.acme.missileinabox.common.entity.fields;

public class ActivityFields {

Any idea what i'm foobaring? I posted the question here with no response.

Best Solution

You may need to specify a <fileset>, possibly containing one or more <patternset>'s, as discussed under the <fileset> topic in <clover-setup>.

Addendum: If you change <files> to <fileset>, you can use the latter's implicit <patternset> unchanged:

    <exclude name="**/*" />
    <exclude name="**/entity/fields/*.java" />

Alternatively, use <files> and nest an explicit <patternset>:

        <exclude name="**/*" />
        <exclude name="**/entity/fields/*.java" />
Related Question