2

Greetings,

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\(.*\).*" />
    <files>
        <exclude name="**/*Test.java" />
        <exclude name="**/entity/fields/*.java" />
    </files>
</clover-setup>

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.

MeBigFatGuy
  • 28,272
  • 7
  • 61
  • 66

1 Answers1

1

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:

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

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

<files>
    <patternset>
        <exclude name="**/*Test.java" />
        <exclude name="**/entity/fields/*.java" />
    </patternset>
</files>
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • 1
    See also [Why does Clover instrument classes I have excluded](http://confluence.atlassian.com/pages/viewpage.action?pageId=79986960)? – trashgod Apr 26 '11 at 16:20
  • hmm maybe this, `Excluded files are still registered in the Clover database:` -- checking – MeBigFatGuy Apr 26 '11 at 18:19
  • [Using Coverage Contexts](http://confluence.atlassian.com/display/CLOVER/Using+Coverage+Contexts) mentions, "At report time, you can specify which contexts you would like to exclude in the coverage report." Is that an alternative? – trashgod Apr 26 '11 at 19:31
  • using the patternset in files, i saw no difference... I tried to copy the filter to report generation time.. no love for me. – MeBigFatGuy Apr 26 '11 at 21:46
  • Tabs in the source? Try `regexp="(.* )?public[ \t]String[ \t]toString\(.*\).*"`. – trashgod Apr 26 '11 at 23:57
  • well that might be true somewhere, but, toString `IS` getting removed from the reports. – MeBigFatGuy Apr 27 '11 at 05:42
  • That makes sense. Looking at [``](http://confluence.atlassian.com/display/CLOVER/clover-setup), I don't see an example in which `` contains a nested ``. Perhaps the should be a level up, and the `*Test` files are being excluded for an unrelated reason. – trashgod Apr 27 '11 at 06:10
  • sorry, poor SO formatting made it look like fileset was a nested element of ``, notice that methodContext is an empty tag. i fixed it – MeBigFatGuy Apr 27 '11 at 21:42