我尝试使用gradle设置自定义findbugs任务,该任务将具有与默认值不同的pluginClasspath.
因此,默认任务应使用默认的FindBugs规则,而自定义任务应使用findbugs-security规则.我的配置如下所示:
dependencies {
findbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.4.4'
}
findbugs {
// general config
}
task findbugsSecurity(type: FindBugs, dependsOn: classes) {
classes = fileTree(project.sourceSets.main.output.classesDir)
source = project.sourceSets.main.java.srcDirs
classpath = files()
pluginClasspath = files(configurations.findbugsPlugins.asPath)
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我现在运行findbugsMain任务,它还包括来自findbugs-security的检查!
如何配置它以便findbugs-security检查仅用于自定义任务?
正如您可能已经猜到的那样,听起来配置findbugsSecurity任务也会改变行为。findbugsMain
技巧是使用新的配置,因为 Gradle 会自动查找 findbugsPlugins 配置的依赖项,并将应用于 findbugs 的所有调用(请参阅FindBugs DSL 的 pluginClasspath 部分):
configurations {
foo
}
dependencies {
// Important that we use a new configuration here because Gradle will use the findbugsPlugins configurations by default
foo 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.4.4'
}
findbugs { /* whatever */ }
task findbugsSecurity(type: FindBugs, dependsOn: classes) {
classes = fileTree(project.sourceSets.main.output.classesDir)
source = project.sourceSets.main.java.srcDirs
classpath = files()
pluginClasspath = files(configurations.foo.asPath)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1176 次 |
| 最近记录: |