Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio - FindBugs excludeFilter file is working for IDEA plugin, but not for Gradle plugin

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?

like image 453
user3829751 Avatar asked Sep 15 '15 19:09

user3829751


1 Answers

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

    .....

}
like image 86
user3829751 Avatar answered Oct 14 '22 17:10

user3829751