Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using fb-contrib library with Gradle's FindBugs plugin

Is it possible to integrate the fb-contrib library with Gradle's FindBugs plugin? I've been looking around for a solution for a while but so far I haven't found anything...

If it helps, here's the script I have right now. It's a work in progress but the report is generated correctly.

apply plugin: "findbugs"

task findbugs(type: FindBugs) {

    classes = fileTree(project.rootDir.absolutePath).include("**/*.class");
    source = fileTree(project.rootDir.absolutePath).include("**/*.java");
    classpath = files()

    findbugs {
            toolVersion = "2.0.3"
            ignoreFailures = true
            effort = "max"
            reportLevel = "low"
            reportsDir = file("${projectDir}/reports/findbugs")
            sourceSets = [it.sourceSets.main, it.sourceSets.test]
    }

    tasks.withType(FindBugs) {
            reports {
                    xml.enabled = false
                    html.enabled = true
            }
     }
}

Thanks in advance for any answer.

like image 514
DPR Avatar asked Feb 12 '14 19:02

DPR


2 Answers

I just came across this very same problem. I was able to solve it as follows:

apply plugin: 'findbugs'

dependencies {
    // We need to manually set this first, or the plugin is not loaded
    findbugs 'com.google.code.findbugs:findbugs:3.0.0'
    findbugs configurations.findbugsPlugins.dependencies

    // To keep everything tidy, we set these apart
    findbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:6.0.0'
}

task findbugs(type: FindBugs) {
   // Add all your config here ...

   pluginClasspath = project.configurations.findbugsPlugins
}

Hope that helps!

You can add more Findbugs plugins just by adding them under dependencies for findbugsPlugins

like image 168
Johnco Avatar answered Nov 03 '22 02:11

Johnco


if you place the fb-contrib.jar in Findbugs' plugin directory, it should just automagically get picked up, i would think. Never tried with Gradle tho.

like image 40
MeBigFatGuy Avatar answered Nov 03 '22 02:11

MeBigFatGuy