hm2qrw
Last Updated: February 25, 2016
·
1.61K
· chilicat

Gradle Findbugs disabled by default

Gradle Findbugs: A gradle script which disables findbugs until "findbugs" task is in the task graph.

allprojects {
    // Marker Task to enable findbugs.
    task findbugs(
        group: "Verification", 
        description: "Marker task to enabled findbugs."
    )
}

subprojects {
    apply plugin: 'findbugs'

    findbugs { 
        // your findbugs configuration.
        ignoreFailures = true 
    }

    gradle.taskGraph.whenReady { taskGraph ->
        tasks.findbugsMain.onlyIf { 
            taskGraph.hasTask((tasks.findbugs))
        }
        tasks.findbugsTest.onlyIf {  
               taskGraph.hasTask((tasks.findbugs)) 
        }
    }
}

Now findbugs will only be executed if you do following:

gradlew findbugs build