Spot Bugs Extension
SpotBugsExtension is an extension used to set up the SpotBugs Gradle plugin. All properties in this extension act as default properties for all instances of SpotBugsTask are optional.
Usage
Once you've applied the SpotBugs Gradle plugin to your project, configure it as shown below:
// Required: Gradle 8.2 or higher
spotbugs {
ignoreFailures = false
showStackTraces = true
showProgress = true
effort = com.github.spotbugs.snom.Effort.DEFAULT
reportLevel = com.github.spotbugs.snom.Confidence.DEFAULT
visitors = listOf("FindSqlInjection", "SwitchFallthrough")
omitVisitors = listOf("FindNonShortCircuit")
reportsDir = file("$buildDir/spotbugs")
includeFilter = file("include.xml")
excludeFilter = file("exclude.xml")
baselineFile = file("baseline.xml")
onlyAnalyze = listOf("com.foobar.MyClass", "com.foobar.mypkg.*")
maxHeapSize = "1g"
extraArgs = listOf("-nested:false")
jvmArgs = listOf("-Duser.language=ja")
runOnCheck = true
}
See also SpotBugs Manual about configuration.
Properties
Property to set the baseline file. This file is a Spotbugs result file, and all bugs reported in this file will not be reported in the final output.
Property to adjust SpotBugs detectors. Default value is Effort.DEFAULT.
Property to set the filter file to limit which bug should be reported.
Property to set the filter file to limit which bug should be reported.
Property to specify the max heap size (-Xmx
option) of JVM process. Default value is empty so the default configuration made by Gradle will be used.
Property to disable visitors (detectors) for analysis. Default is empty that means SpotBugs omits no visitor.
Property to specify the target classes for analysis. Default value is empty that means all classes are analyzed.
Property to specify the name of project. Some reporting formats use this property. Default value is the name of your Gradle project.
Property to specify the level to report bugs. Default value is Confidence.DEFAULT.
Property to set the directory to generate report files. Default is "$buildDir/reports/spotbugs"
.
Property to specify if the SpotBugs tasks should automatically be marked as dependencies of the check task. Defaults to true.
Property to enable progress reporting during the analysis. Default value is false
.