Riv*_*ivi 5 static-analysis findbugs gradle
我正在尝试在build.gradle文件中使用findbugs插件,以便使开发人员个人构建失败,但它无法正常工作.虽然插件创建报告但构建不会失败.我曾尝试使用ignoreFailures属性"玩",但这也不顺利.
我使用了这个答案如何编写一个自定义的gradle任务,不要忽略Findbugs违规,但在分析完成后失败,并且它有效,但我不喜欢解析报告,感觉就像一个黑客.
有没有简单的方法(比如'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')
}
}
Run Code Online (Sandbox Code Playgroud)
小智 3
好吧,如果 Findbugs 发现的问题不是“高优先级”错误,则不会按照您明确设置的方式报告它们:
reportLevel = "high"
Run Code Online (Sandbox Code Playgroud)
Gradle 文档说得很清楚:
报告错误的优先级阈值。如果设置为低,则报告所有错误。如果设置为中(默认),则会报告中优先级和高优先级错误。如果设置为高,则仅报告高优先级错误。
因此,我的建议是在 findbugs 配置中执行此操作:
ignoreFailures = false
reportLevel = "low"
Run Code Online (Sandbox Code Playgroud)
这对我有用。
归档时间: |
|
查看次数: |
2401 次 |
最近记录: |