The FindBugs plugin performs quality checks on your project’s Java source files using FindBugs and generates reports from these checks.
To use the FindBugs plugin, include the following in your build script:
The plugin adds a number of tasks to the project that perform the quality checks. You can execute the checks by running gradle check
.
Note that Findbugs will run with the same Java version used to run Gradle.
The FindBugs plugin adds the following tasks to the project:
FindBugs plugin - tasks
Task name | Depends on | Type | Description |
|
|
Runs FindBugs against the production Java source files. |
|
|
|
Runs FindBugs against the test Java source files. |
|
|
|
Runs FindBugs against the given source set’s Java source files. |
The FindBugs plugin adds the following dependencies to tasks defined by the Java plugin.
FindBugs plugin - additional task dependencies
Task name | Depends on |
|
All FindBugs tasks, including |
The FindBugs plugin adds the following dependency configurations:
FindBugs plugin - dependency configurations
Name | Meaning |
|
The FindBugs libraries to use |
See the FindBugsExtension
class in the API documentation.
The HTML report generated by the FindBugs
task can be customized using a XSLT stylesheet, for example to highlight specific errors or change its appearance:
Example: Customizing the HTML report
build.gradle
tasks.withType(FindBugs) {
reports {
xml.enabled false
html.enabled true
html.stylesheet resources.text.fromFile('config/xsl/findbugs-custom.xsl')
}
}