This is an unofficial Gradle Plugin to run SpotBugs on Java and Android project.
This Gradle plugin is designed to solve the following problems in the official one:
- Remove any dependency on the Gradle's internal API
- Solve mutability problem for the build contains multiple projects and/or sourceSet
- Native Support for the Parallel Build
- Native Support for the Android project
- Missing user document about how to use extension and task
Apply the plugin to your project. Refer the Gradle Plugin portal about the detail of installation procedure.
Configure spotbugs
extension to configure the behaviour of tasks:
spotbugs {
ignoreFailures = false
showProgress = true
effort = 'default'
reportLevel = 'default'
visitors = [ 'FindSqlInjection', 'SwitchFallthrough' ]
omitVisitors = [ 'FindNonShortCircuit' ]
reportsDir = file("$buildDir/spotbugs")
includeFilter = file("include.xml")
excludeFilter = file("exclude.xml")
onlyAnalyze = [ 'com.foobar.MyClass', 'com.foobar.mypkg.*' ]
maxHeapSize = '1g'
extraArgs = [ '-nested:false' ]
jvmArgs = [ '-Duser.language=ja' ]
}
Configure spotbugsPlugin
to apply any SpotBugs plugin:
dependencies {
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.7.1'
}
Configure spotbugs
to choose your favorite SpotBugs version:
dependencies {
spotbugs 'com.github.spotbugs:spotbugs:4.0.0'
}
Apply this plugin with the java
plugin to your project,
then SpotBugsTask
will be generated for each existing sourceSet.
If you want to create and configure SpotBugsTask
by own, apply the base plugin (jp.skypencil.spotbugs.snom-base
) instead, then it won't create tasks automatically.
TBU
Configure SpotBugsTask
directly,
to set task-specific properties.
// Example to configure HTML report
spotbugsMain {
reports {
html {
enabled = true
destination = file("$buildDir/reports/spotbugs/main/spotbugs.html")
stylesheet = 'fancy-hist.xsl'
}
}
}
By default, this Gradle Plugin uses the SpotBugs version listed in this table.
You can change SpotBugs version by the toolVersion
property of the spotbugs extension or the spotbugs
configuration.
Gradle Plugin | SpotBugs |
---|---|
5.0.0 | 4.0.0 |
Copyright © 2019-present SpotBugs Team