用于多项目设置的 Spotbugs 配置
Spotbugs configuration for multi project setup
我有一个多项目 Gradle 设置如下:
RootProject
|
---- ProjectA
|
---- ProjectB
|
---- ProjectC
我想将 SpotBugs 应用于我的所有项目。
在每个项目中执行以下操作显然有效。
例如,ProjectA
的 build.gradle
中的以下内容:
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
}
}
但是,我不想在所有项目的 build.gradle
文件中复制这段代码。
如何将其提取到 RootProject
的构建文件中。
例如,在以下块中:
configure(subprojects.findAll {it.name != 'SomeProjectToIgnore'}) {
// how to configure spotbugs here ?
}
按原样移动方块不起作用。
您可以通过以下方式在根项目的 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 ]
}
}
我有一个多项目 Gradle 设置如下:
RootProject
|
---- ProjectA
|
---- ProjectB
|
---- ProjectC
我想将 SpotBugs 应用于我的所有项目。
在每个项目中执行以下操作显然有效。
例如,ProjectA
的 build.gradle
中的以下内容:
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
}
}
但是,我不想在所有项目的 build.gradle
文件中复制这段代码。
如何将其提取到 RootProject
的构建文件中。
例如,在以下块中:
configure(subprojects.findAll {it.name != 'SomeProjectToIgnore'}) {
// how to configure spotbugs here ?
}
按原样移动方块不起作用。
您可以通过以下方式在根项目的 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 ]
}
}