Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Gradle Checkstyle plug-in


May 25, 2021 Gradle


Table of contents


Checkstyle plug-in

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.

Usage

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.

Tasks

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 project layout

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

Rely on management

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