在Gradle的FindBugs插件中使用fb-contrib库 [英] Using fb-contrib library with Gradle's FindBugs plugin

查看:799
本文介绍了在Gradle的FindBugs插件中使用fb-contrib库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将 fb-contrib 库与Gradle的 FindBugs插件?我一直在寻找一个解决方案一段时间,但到目前为止我还没有找到任何东西......



如果有帮助,这里是我现在的脚本。

  apply plugin:findbugs

这是一项正在进行的工作,但报告正确生成。任务findbugs(类型:FindBugs){

classes = fileTree(project.rootDir.absolutePath).include(** / *。class);
source = fileTree(project.rootDir.absolutePath).include(** / *。java);
classpath = files()

findbugs {
toolVersion =2.0.3
ignoreFailures = true
effort =max
reportLevel =low
reportsDir = file($ {projectDir} / reports / findbugs)
sourceSets = [it.sourceSets.main,it.sourceSets.test]
}

tasks.withType(FindBugs){
reports {
xml.enabled = false
html.enabled = true
}
}
}

预先感谢您的任何答案。

解决方案

我刚碰到这个同样的问题。我能够解决它,如下所示:

  apply plugin:'findbugs'

dependencies {
//我们需要先手动设置,或者插件没有加载
findbugs'com.google.code.findbugs:findbugs:3.0.0'
findbugs configurations.findbugsPlugins.dependencies

//为了保持一切整洁,我们将这些设置分开
findbugsPlugins'com.mebigfatguy.fb-contrib:fb-contrib:6.0.0'
}

任务findbugs(类型:FindBugs){
//在此添加所有配置...

pluginClasspath = project.configurations.findbugsPlugins
}

希望有帮助!

您可以添加更多Findbugs插件通过在 findbugsPlugins


的依赖关系下添加它们

Is it possible to integrate the fb-contrib library with Gradle's FindBugs plugin? I've been looking around for a solution for a while but so far I haven't found anything...

If it helps, here's the script I have right now. It's a work in progress but the report is generated correctly.

apply plugin: "findbugs"

task findbugs(type: FindBugs) {

    classes = fileTree(project.rootDir.absolutePath).include("**/*.class");
    source = fileTree(project.rootDir.absolutePath).include("**/*.java");
    classpath = files()

    findbugs {
            toolVersion = "2.0.3"
            ignoreFailures = true
            effort = "max"
            reportLevel = "low"
            reportsDir = file("${projectDir}/reports/findbugs")
            sourceSets = [it.sourceSets.main, it.sourceSets.test]
    }

    tasks.withType(FindBugs) {
            reports {
                    xml.enabled = false
                    html.enabled = true
            }
     }
}

Thanks in advance for any answer.

解决方案

I just came across this very same problem. I was able to solve it as follows:

apply plugin: 'findbugs'

dependencies {
    // We need to manually set this first, or the plugin is not loaded
    findbugs 'com.google.code.findbugs:findbugs:3.0.0'
    findbugs configurations.findbugsPlugins.dependencies

    // To keep everything tidy, we set these apart
    findbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:6.0.0'
}

task findbugs(type: FindBugs) {
   // Add all your config here ...

   pluginClasspath = project.configurations.findbugsPlugins
}

Hope that helps!

You can add more Findbugs plugins just by adding them under dependencies for findbugsPlugins

这篇关于在Gradle的FindBugs插件中使用fb-contrib库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆