The code quality plugin adds tasks which perform code quality checks and generate reports from these checks. The following tools are supported:
To use the code quality plugin, include in your build script:
When used with the Java plugin, the code quality plugin adds the following tasks to the project:
Table 26.1. Code quality plugin - Java tasks
Task name | Depends on | Type | Description |
checkstyleMain
|
- | Checkstyle |
Runs Checkstyle against the production Java source files. |
checkstyleTest
|
compile |
Checkstyle |
Runs Checkstyle against the test Java source files. |
checkstyle
|
- | Checkstyle |
Runs Checkstyle against the given source set's Java source files. |
When used with the Groovy plugin, the code quality plugin adds the following tasks to the project:
Table 26.2. Code quality plugin - tasks
The Code quality plugin adds the following dependencies to tasks added by the Java plugin.
Table 26.3. Code quality plugin - additional task dependencies
Task name | Depends on |
check | All Checkstyle and CodeNarc tasks, including checkstyleMain ,
checkstyleTest ,
codenarcMain and
codenarcTest
|
The code quality plugin expects the following project layout:
Table 26.4. Code quality plugin - project layout
File | Meaning |
config/checkstyle/checkstyle.xml
|
Checkstyle configuration file |
config/codenarc/codenarc.xml
|
CodeNarc configuration file |
When used with the Java plugin, the code quality plugin adds the following convention properties to the project:
Table 26.5. Code quality plugin - convention properties
Property name | Type | Default value | Description |
checkstyleConfigFileName
|
String
|
config/checkstyle/checkstyle.xml
|
The location of the Checkstyle configuration file, relative to the project directory. |
checkstyleConfigFile
|
File (read-only)
|
|
The Checkstyle configuration file. |
checkstyleResultsDirName
|
String
|
checkstyle
|
The name of the directory to generate Checkstyle results into, relative to the build directory. |
checkstyleResultsDir
|
File (read-only)
|
|
The directory to generate Checkstyle results into. |
checkstyleProperties
|
Map
|
[:]
|
The properties to use when loading the Checkstyle configuration. |
These convention properties are provided by a convention object of type
JavaCodeQualityPluginConvention
.
When used with the Groovy plugin, the code quality plugin adds the following convention properties to the project:
Table 26.6. Code quality plugin - convention properties
Property name | Type | Default value | Description |
codeNarcConfigFileName
|
String
|
config/codenarc/codenarc.xml
|
The location of the CodeNarc configuration file, relative to the project directory. |
codeNarcConfigFile
|
File (read-only)
|
|
The CodeNarc configuration file. |
codeNarcReportsDirName
|
String
|
codenarc
|
The name of the directory to generate CodeNarc reports into, relative to the reports directory. |
codeNarcReportsDir
|
File (read-only)
|
|
The directory to generate CodeNarc reports into. |
These convention properties are provided by a convention object of type
GroovyCodeQualityPluginConvention
.