2015-03-11 10 views
5

Sto cercando di usare il plugin findbugs nel mio file build.gradle per fallire la build personale degli sviluppatori ma non funziona. Sebbene il plugin crei i report, la compilazione non fallirà. Ho provato a "giocare" con la proprietà ignoreFailures ma non è andata bene neanche così.Findbugs Il plugin Gradle non fallirà la build

Ho usato questa risposta How to write a customized gradle task to not to ignore Findbugs violations but fail after the analysis is completed, e ha funzionato, ma non mi piace analizzare i rapporti e sembra un trucco.

Non c'è un modo semplice (come dovrebbe essere 'ignoreFailures') per fallire la build di Gradle usando findbugs? C'è un altro quadro adatto per farlo?

Aggiunto il file build.gradle:

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') 
} 
} 
+0

Findbugs non sta fallendo affatto. anche quando ignoreFailures = false (sebbene sia l'impostazione predefinita) – Rivi

+0

Puoi fornire un esempio che riproduca il problema? – Opal

+0

Aggiunto il file build.gradle – Rivi

risposta

2

Beh, se i reperti problemi FindBugs non sono bug "ad alta priorità", non saranno riportati come si sta impostando in modo esplicito:

reportLevel = "high" 

Il Gradle documentation è chiaro al riguardo:

La soglia di priorità per la segnalazione di bachi. Se impostato su basso, vengono segnalati tutti i bug. Se impostato su medio (predefinito), vengono segnalati errori di media e alta priorità. Se impostato su alto, vengono segnalati solo i bug con priorità alta.

Quindi, la mia raccomandazione è di fare questo nella configurazione findbugs:

ignoreFailures = false 
reportLevel = "low" 

che non lavoro per me.

Problemi correlati