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?
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
.....
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With