I have generated sources in a specific package added to the main java sourceset. These classes are picked up by checkstyle, findbugs and pmd.
While I can use
checkstyleMain.exclude '**/some/package/**'
to exclude the generated sources (they’re generated to a specific package), this does not work for findbugs (findbugsMain.exclude …): findbugs reports style issues for the generated classes.
Is this a bug, or what am I doing wrong? I’m using gradle 1.7 with findbugs 2.0.1 btw.
Cheers, Martin
Can you give an example for a reported style issue?
Here’s the example:
<BugInstance type="EQ_UNUSUAL" priority="2" abbrev="Eq" category="STYLE">
<Class classname="org.company.some.package.Brands">
<SourceLine classname="org.company.some.package.Brands" start="68" end="186" sourcefile="Brands.java" sourcepath="org/company/some/package/Brands.java"/>
</Class>
<Method classname="org.company.some.package.Brands" name="equals" signature="(Ljava/lang/Object;)Z" isStatic="false">
<SourceLine classname="org.company.some.package.Brands" start="124" end="125" startBytecode="0" endBytecode="78" sourcefile="Brands.java" sourcepath="org/company/some/package/Brands.java"/>
</Method>
</BugInstance>
Btw, the pattern was “/some/package/”, the stars are removed by the syntax highlighter/formatter.
The ‘FindBugs.include/exclude’ properties are inherited from ‘SourceTask’ and operates on source files. However, FindBugs analysis mainly operates on class files. A better, FindBugs specific way to include/exclude certain classes is to use ‘FindBugs.includeFilter/excludeFilter’. For details, see ‘FindBugs’ in the Gradle Build Language Reference and the FindBugs docs.
It’s also possible to configure the same properties on the ‘findbugs’ object, which is of type ‘FindBugsExtension’ (see Javadoc). Configuring ‘findbugs’ has the same effect as configuring all FindBugs tasks for the current project.
Yes, I’ve used excludeFilter for now. Is there an example, how include/exclude properties can be used with findbugs?
Again ant pattern stars removed - you probably know what it should look like
Not quite sure what you mean by that. As I said, ‘include’/‘exclude’ operate on source files, which FindBugs mainly (solely?) uses for reporting purposes. Therefore, ‘includeFilter’/‘excludeFilter’ is the way to go.
Does include/exclude translate to any findbugs option/parameter? What would be a use case to use include/exclude with findbugs?
Basically it would help if the documentation would tell which property in gradle translates to which property in findbugs (or in the findbugs ant task respectively). Maybe I should just read the sources, from there it should become clear
include/exclude filters the sources passed to FindBugs. If you can think of a way to improve the dsl docs, a pull request is appreciated.