May 25, 2021 Gradle
The Checkstyle plug-in uses Checkstyle to perform quality checks on your project's Java source files and generate reports from the results of the checks.
To use the Checkstyle plug-in, include the following statement in the build script:
Use the Checkstyle plug-in
build.gradle
apply plugin: 'checkstyle'
The plug-in adds a lot of quality checks to your project. You can perform a check by running the gradle check.
The Checkstyle plug-in adds the following tasks to the project:
Table 29.1. Checkstyle plug-in - tasks
The name of the task | Depends on | Type | Describe |
checkstyleMain
|
classes
|
checkstyle | Run Checkstyle for production Java source files. |
checkstyleTest
|
testClasses
|
checkstyle | Run Checkstyle against the test Java source file. |
SourceSet
|
sourceSet
Classes
|
checkstyle | Run Checkstyle on the Java source file for source set. |
The Checkstyle plug-in adds the following dependencies to the tasks that the Java plug-in joins.
Table 29.2. Checkstyle plug-in - additional task dependency
The name of the task | Depends on |
check
|
All Checkstyle tasks,
checkstyleTest
|
The Checkstyle plug-in is expected to be the following project layout:
Table 29.3. Checkstyle plug-in - project layout
File | Significance |
config/checkstyle/checkstyle.xml
|
Checkstyle profile |
The Checkstyle plug-in adds the following dependency configurations:
Table 29.4. Checkstyle Plug-in - Dependent on Configuration
Name | Significance |
checkstyle
|
The Checkstyle library used |