将fb-contrib库与Gradle的FindBugs插件一起使用

DPR*_*DPR 7 findbugs gradle

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

如果它有帮助,这是我现在的脚本.这是一项正在进行的工作,但报告已正确生成.

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
            }
     }
}
Run Code Online (Sandbox Code Playgroud)

提前感谢您的回答.

Joh*_*nco 6

我刚刚遇到了同样的问题.我能够解决它如下:

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
}
Run Code Online (Sandbox Code Playgroud)

希望有所帮助!

您可以添加更多Findbugs插件,只需在依赖项下添加它们即可 findbugsPlugins