Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Findbugs Gradle plugin won't fail the build

I'm trying to use findbugs plugin in my build.gradle file in order to fail the developers personal build but it's not working. Although the plugin creates the reports the build won't fail. I have tried to 'play' with the ignoreFailures property but that didn't go well either.

I used this answer How to write a customized gradle task to not to ignore Findbugs violations but fail after the analysis is completed, and it worked but I don't like to parse the reports and it feels like a hack.

Is there no simple way (like 'ignoreFailures' should be) to fail the Gradle build using findbugs? Is there another suitable framework to do that?

Added the build.gradle file:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath "com.bmuschko:gradle-tomcat-plugin:2.1"
    }
}

subprojects {
apply plugin:'java'
apply plugin:'eclipse'


apply plugin: "findbugs"
findbugs {
    reportsDir = file("$project.buildDir/findbugsReports")
    effort = "max"
    reportLevel = "high"
}

build.dependsOn 'check'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

repositories {
    maven { url "http://repo.maven.apache.org/maven2" }
}

dependencies {

    compile group: 'javax.validation', name: 'validation-api', version:'1.1.0.Final'
    compile group: 'org.springframework.security', name: 'spring-security-web', version: "${VERSION_SPRING_SECURITY}"
    compile group: 'org.springframework.security', name: 'spring-security-config', version: "${VERSION_SPRING_SECURITY}"

    // Spring dependency injection container:
    compile (group: 'org.springframework', name: 'spring-context', version:"${VERSION_SPRING}") {
        exclude(module: 'commons-logging')
    }

    compile group: 'javax.inject', name: 'javax.inject', version:'1'
    compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.10'
    runtime group: 'org.slf4j', name: 'jcl-over-slf4j', version:'1.7.10'
    runtime group: 'org.slf4j', name: 'slf4j-log4j12', version:'1.7.10'
    runtime group: 'org.aspectj', name: 'aspectjrt', version:"${VERSION_ASPECTJ}"
    runtime group: 'org.aspectj', name: 'aspectjweaver', version:"${VERSION_ASPECTJ}"

    testCompile group: 'org.springframework', name: 'spring-test', version:"${VERSION_SPRING}"
    testCompile group: 'junit', name: 'junit', version:'4.12'



    compile group: 'commons-pool', name: 'commons-pool', version:'1.6'

    compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version:'2.5.1'
    compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-mrbean', version:'2.5.1'

}
}

project(':server:application'){
dependencies {

    compile(project(':server:services')) {
        exclude(module: ':server:data-access')
    }
    compile group: 'org.springframework', name: 'spring-webmvc', version:"${VERSION_SPRING}"
    compile project(':server:dto'), project(':server:utils'), project(':server:model')
}
}
like image 916
Rivi Avatar asked Oct 20 '22 16:10

Rivi


1 Answers

Well, if the issues Findbugs finds are not "high priority" bugs, they won't be reported as you're explicitly setting:

reportLevel = "high"

The Gradle documentation is clear about that:

The priority threshold for reporting bugs. If set to low, all bugs are reported. If set to medium (the default), medium and high priority bugs are reported. If set to high, only high priority bugs are reported.

So, my recommendation is to do this in your findbugs configuration:

ignoreFailures = false
reportLevel = "low"

That does work for me.

like image 60
johnmartel Avatar answered Oct 22 '22 21:10

johnmartel