将findsecbugs插件与Gradle的findbugs插件集成

时间:2015-12-04 10:16:07

标签: gradle findbugs

我计划使用findsecbugs插件使用findbugs插件扫描java代码中的漏洞。我正在寻找包含在我的build.gradle文件中的配置参数。类似于this

P.S。:我可以在Gradle中使用FindBugs插件。

1 个答案:

答案 0 :(得分:2)

我试过并找到了工作配置。发布以下工作配置:

  apply plugin: 'java'  
  apply plugin: 'findbugs'    
  apply plugin: 'maven'  
  apply plugin: 'signing'  

  sourceCompatibility = 1.7

  dependencies {  

  findbugs 'com.google.code.findbugs:findbugs:3.0.0'
  findbugs configurations.findbugsPlugins.dependencies

  // Here we specify the findbugsPlugins
  findbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.2.0'
  }  
 task findbugs(type: FindBugs) {

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

  findbugs {
   toolVersion = "3.0.0"
   sourceSets = [sourceSets.main]
   ignoreFailures = true
   reportsDir = file("$project.buildDir/findbugsReports")
   effort = "max"
   reportLevel = "high"
   includeFilter = file("$rootProject.projectDir/include.xml")
   excludeFilter = file("$rootProject.projectDir/exclude.xml")
  }

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