SpotBugsExtension

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

Link copied to clipboard
abstract val baselineFile: RegularFileProperty

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.

Link copied to clipboard
abstract val effort: Property<Effort>

Property to adjust SpotBugs detectors. Default value is Effort.DEFAULT.

Link copied to clipboard
abstract val excludeFilter: RegularFileProperty

Property to set the filter file to limit which bug should be reported.

Link copied to clipboard
abstract val extraArgs: ListProperty<String>

Property to specify the extra arguments for SpotBugs. Default value is empty so SpotBugs will get no extra argument.

Link copied to clipboard
abstract val ignoreFailures: Property<Boolean>
Link copied to clipboard
abstract val includeFilter: RegularFileProperty

Property to set the filter file to limit which bug should be reported.

Link copied to clipboard
abstract val jvmArgs: ListProperty<String>

Property to specify the extra arguments for JVM process. Default value is empty so JVM process will get no extra argument.

Link copied to clipboard
abstract val maxHeapSize: Property<String>

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.

Link copied to clipboard
abstract val omitVisitors: ListProperty<String>

Property to disable visitors (detectors) for analysis. Default is empty that means SpotBugs omits no visitor.

Link copied to clipboard
abstract val onlyAnalyze: ListProperty<String>

Property to specify the target classes for analysis. Default value is empty that means all classes are analyzed.

Link copied to clipboard
abstract val projectName: Property<String>

Property to specify the name of project. Some reporting formats use this property. Default value is the name of your Gradle project.

Link copied to clipboard
abstract val release: Property<String>

Property to specify the release identifier of project. Some reporting formats use this property. Default value is the version of your Gradle project.

Link copied to clipboard
abstract val reportLevel: Property<Confidence>

Property to specify the level to report bugs. Default value is Confidence.DEFAULT.

Link copied to clipboard
abstract val reportsDir: DirectoryProperty

Property to set the directory to generate report files. Default is "$buildDir/reports/spotbugs".

Link copied to clipboard
abstract val runOnCheck: Property<Boolean>

Property to specify if the SpotBugs tasks should automatically be marked as dependencies of the check task. Defaults to true.

Link copied to clipboard
abstract val showProgress: Property<Boolean>

Property to enable progress reporting during the analysis. Default value is false.

Link copied to clipboard
abstract val showStackTraces: Property<Boolean>
Link copied to clipboard
abstract val toolVersion: Property<String>
Link copied to clipboard
abstract val useAuxclasspathFile: Property<Boolean>
Link copied to clipboard
abstract val useJavaToolchains: Property<Boolean>
Link copied to clipboard
abstract val visitors: ListProperty<String>

Property to enable visitors (detectors) for analysis. Default is empty that means all visitors run analysis.