gpt4 book ai didi

gradle - Findbugs Gradle 插件不会使构建失败

转载 作者:行者123 更新时间:2023-12-04 20:39:35 25 4
gpt4 key购买 nike

我试图在我的 build.gradle 文件中使用 findbugs 插件,以使开发人员的个人构建失败,但它不起作用。
尽管插件创建了报告,但构建不会失败。
我试图“玩”忽略失败 属性(property),但也不顺利。

我用过这个答案 How to write a customized gradle task to not to ignore Findbugs violations but fail after the analysis is completed ,它奏效了,但我不喜欢解析报告,感觉就像一个黑客。

有没有简单的方法(如“ignoreFailures”应该是)使用 findbugs 使 Gradle 构建失败?有没有其他合适的框架来做到这一点?

添加了 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')
}
}

最佳答案

好吧,如果 Findbugs 发现的问题不是“高优先级”错误,则不会在您明确设置时报告它们:

reportLevel = "high"

Gradle documentation很清楚:

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.



因此,我的建议是在您的 findbugs 配置中执行此操作:
ignoreFailures = false
reportLevel = "low"

这对我有用。

关于gradle - Findbugs Gradle 插件不会使构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28982032/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com