KARASZI István
KARASZI István

Reputation: 31467

FindBugs does not exclude the filtered patterns with Gradle

I want to setup the FindBugsExtension to Gradle. It works but I'm unable to exclude specific patterns with the excludeFilter option.

I have the following gradle FindBugs definition:

findbugs {
    toolVersion = "2.0.1"
    reportsDir = file("$project.buildDir/findbugsReports")
    effort = "max"
    reportLevel = "high"
    excludeFilter = file("$rootProject.projectDir/config/findbugs/excludeFilter.xml")
}

In the excludeFilter.xml I have the following exclude defined:

<FindBugsFilter>
  <Match>
    <Bug pattern="NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE"/>
  </Match>
</FindBugsFilter>

But when I run gradle findBugsMain it fails because it could find FindBugs errors:

<BugCollection version="2.0.1" sequence="0" timestamp="1348055542169" analysisTimestamp="1348055545581" release="">
  <!-- ... -->
  <BugInstance type="NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE" priority="2" abbrev="NP" category="STYLE">
    <!-- ... -->

Upvotes: 0

Views: 2370

Answers (1)

KARASZI Istv&#225;n
KARASZI Istv&#225;n

Reputation: 31467

Okay, I've found the solution from here.

Opposed to the documentation the excludeFilter needs to be defined per task due to a bug in Gradle version 1.2.

So the full configuration would look like this for 1.2:

findbugs {
    toolVersion = "2.0.1"
    reportsDir = file("$project.buildDir/findbugsReports")
    effort = "max"
    reportLevel = "high"
}

tasks.withType(FindBugs) {
    excludeFilter = file("$rootProject.projectDir/config/findbugs/excludeFilter.xml")
}

Upvotes: 3

Related Questions