Vic*_*cky 5 java gradle spotbugs
我有一个像这样的多项目 Gradle 设置:
RootProject
|
---- ProjectA
|
---- ProjectB
|
---- ProjectC
Run Code Online (Sandbox Code Playgroud)
我想将 SpotBugs 应用于我的所有项目。
在每个项目中执行以下操作明确有效。
例如,在build.gradleof 中的以下内容ProjectA:
plugins {
id 'com.github.spotbugs' version '1.6.9'
}
spotbugs {
ignoreFailures = true
effort = 'min'
showProgress = true
reportLevel = 'medium'
// Only run spotbugs directly as too slow to run as CI.
// Will still run spotbugs when called like "gradlew spotbugsMain"
sourceSets = []
}
tasks.withType(com.github.spotbugs.SpotBugsTask) {
reports {
xml.enabled = false
html.enabled = true
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我不想在build.gradle所有项目的文件中复制此代码。
如何将其提取到RootProject的构建文件中。
例如,在以下块中:
configure(subprojects.findAll {it.name != 'SomeProjectToIgnore'}) {
// how to configure spotbugs here ?
}
Run Code Online (Sandbox Code Playgroud)
按原样移动块不起作用。
小智 1
您可以通过以下方式在根项目的 build.gradle 中配置 Spotbugs:
buildscript {
repositories {
maven { url 'maven repository url' }
}
dependencies {
classpath group: 'gradle.plugin.com.github.spotbugs', name: 'spotbugs-gradle-plugin', version: '1.6.5'
}
}
allprojects {
apply plugin: 'com.github.spotbugs'
dependencies {
compileOnly group: 'com.github.spotbugs', name: 'spotbugs-annotations', version: '3.1.8'
spotbugsPlugins group: 'com.h3xstream.findsecbugs', name: 'findsecbugs-plugin', version: '1.8.0'
}
spotbugs {
toolVersion = '3.1.8'
sourceSets = [ sourceSets.main ]
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1816 次 |
| 最近记录: |