Reputation: 712
I have the following exclude filter to ignore all R file classes:
findbugs-exclude-filter.xml
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<Match>
<Class name="~.*\.R\$.*"/>
</Match>
</FindBugsFilter>
When I use it for the FindBugs-IDEA plugin it works.
However, when I use it for the FindBugs Gradle plugin, in a task like so:
build.gradle
apply plugin: 'findbugs'
task myFindBugsTask(type: FindBugs) {
.....
excludeFilter = file("$project.rootDir/findbugs-exclude-filter.xml")
.....
}
I get an error with the message: Cannot read file specified for FindBugs 'excludeFilter' property:
. The report is still successfully generated, but the filter didn't take.
I've tried EVERY solution I found on the interwebs (most of which are very outdated) and I get the same results.
So what gives? Is this a known bug? Am I the only one experiencing this?
Upvotes: 6
Views: 2397
Reputation: 673
Here is the correct filter:
<Match>
<Class name="~.*\.R(\$.*)?" />
</Match>
This marches all R
classes and inner classes.
Upvotes: 0
Reputation: 712
So I found a workaround if anyone is encountering the same issue. The concept is to submit a filtered file tree. My task now looks like this:
apply plugin: 'findbugs'
task myFindBugsTask(type: FindBugs) {
.....
FileTree tree = fileTree("$project.buildDir/intermediates/classes").exclude('**/*R$*.class')
classes = tree
.....
}
Upvotes: 2