checkstyle:checkstyle

Note:This goal should be used as a Maven report.

Full name:

org.apache.maven.plugins:maven-checkstyle-plugin:2.16:checkstyle

Description:

A reporting task that performs Checkstyle analysis and generates an HTML report on any violations that Checkstyle finds.

Attributes:

  • Requires a Maven project to be executed.
  • Requires dependency resolution of artifacts in scope: compile.
  • The goal is thread-safe and supports parallel builds.

Required Parameters

Name Type Since Description
includeResources boolean 2.11 Specifies whether to include the resource directories in the check.
Default value is: true.
User property is: checkstyle.includeResources.
includeTestResources boolean 2.11 Specifies whether to include the test resource directories in the check.
Default value is: true.
User property is: checkstyle.includeTestResources.
includes String - Specifies the names filter of the source files to be used for Checkstyle.
Default value is: **\/*.java.
User property is: checkstyle.includes.
resourceIncludes String 2.11 Specifies the names filter of the resource files to be used for Checkstyle.
Default value is: **/*.properties.
User property is: checkstyle.resourceIncludes.

Optional Parameters

Name Type Since Description
cacheFile String - Specifies the cache file used to speed up Checkstyle on successive runs.
Default value is: ${project.build.directory}/checkstyle-cachefile.
configLocation String -

Specifies the location of the XML configuration to use.

Potential values are a filesystem path, a URL, or a classpath resource. This parameter expects that the contents of the location conform to the xml format (Checkstyle Checker module) configuration of rulesets.

This parameter is resolved as resource, URL, then file. If successfully resolved, the contents of the configuration is copied into the ${project.build.directory}/checkstyle-configuration.xml file before being passed to Checkstyle as a configuration.

There are 2 predefined rulesets included in Maven Checkstyle Plugin:

  • sun_checks.xml: Sun Checks.
  • google_checks.xml: Google Checks.

Default value is: sun_checks.xml.
User property is: checkstyle.config.location.
consoleOutput boolean - Output errors to console.
Default value is: false.
User property is: checkstyle.consoleOutput.
enableFilesSummary boolean - Specifies if the Files summary should be enabled or not.
Default value is: true.
User property is: checkstyle.enable.files.summary.
enableRSS boolean - Specifies if the RSS should be enabled or not.
Default value is: true.
User property is: checkstyle.enable.rss.
enableRulesSummary boolean - Specifies if the Rules summary should be enabled or not.
Default value is: true.
User property is: checkstyle.enable.rules.summary.
enableSeveritySummary boolean - Specifies if the Severity summary should be enabled or not.
Default value is: true.
User property is: checkstyle.enable.severity.summary.
encoding String 2.2 The file encoding to use when reading the source files. If the property project.build.sourceEncoding is not set, the platform default encoding is used. Note: This parameter always overrides the property charset from Checkstyle's TreeWalker module.
Default value is: ${project.build.sourceEncoding}.
User property is: encoding.
excludes String - Specifies the names filter of the source files to be excluded for Checkstyle.
User property is: checkstyle.excludes.
failsOnError boolean - Specifies if the build should fail upon a violation.
Default value is: false.
format String - Deprecated. Use configLocation instead.
Default value is: sun.
headerFile File - Deprecated. Use headerLocation instead.
Default value is: ${basedir}/LICENSE.txt.
headerLocation String 2.0-beta-2

Specifies the location of the License file (a.k.a. the header file) that can be used by Checkstyle to verify that source code has the correct license header.

You need to use ${checkstyle.header.file} in your Checkstyle xml configuration to reference the name of this header file.

For instance:

<module name="RegexpHeader"> <property name="headerFile" value="${checkstyle.header.file}"/> </module>


Default value is: LICENSE.txt.
User property is: checkstyle.header.file.
includeTestSourceDirectory boolean 2.2 Include or not the test source directory/directories to be used for Checkstyle.
Default value is: false.
linkXRef boolean 2.1 Link the violation line numbers to the source xref. Will link automatically if Maven JXR plugin is being used.
Default value is: true.
User property is: linkXRef.
outputFile File - Specifies the path and filename to save the Checkstyle output. The format of the output file is determined by the outputFileFormat parameter.
Default value is: ${project.build.directory}/checkstyle-result.xml.
User property is: checkstyle.output.file.
outputFileFormat String - Specifies the format of the output to be used when writing to the output file. Valid values are "plain" and "xml".
Default value is: xml.
User property is: checkstyle.output.format.
packageNamesFile String - Deprecated. Use packageNamesLocation instead.
packageNamesLocation String 2.0-beta-2

Specifies the location of the package names XML to be used to configure the Checkstyle Packages.

This parameter is resolved as resource, URL, then file. If resolved to a resource, or a URL, the contents of the package names XML is copied into the ${project.build.directory}/checkstyle-packagenames.xml file before being passed to Checkstyle for loading.


propertiesFile File - Deprecated. Use propertiesLocation instead.
propertiesLocation String 2.0-beta-2

Specifies the location of the properties file.

This parameter is resolved as URL, File then resource. If successfully resolved, the contents of the properties location is copied into the ${project.build.directory}/checkstyle-checker.properties file before being passed to Checkstyle for loading.

The contents of the propertiesLocation will be made available to Checkstyle for specifying values for parameters within the xml configuration (specified in the configLocation parameter).


User property is: checkstyle.properties.location.
propertiesURL URL - Deprecated. Use propertiesLocation instead.
propertyExpansion String - Allows for specifying raw property expansion information.
resourceExcludes String 2.11 Specifies the names filter of the resource files to be excluded for Checkstyle.
User property is: checkstyle.resourceExcludes.
skip boolean 2.2 Skip entire check.
Default value is: false.
User property is: checkstyle.skip.
sourceDirectories List 2.13 Specifies the location of the source directories to be used for Checkstyle.
Default value is: ${project.compileSourceRoots}.
sourceDirectory File - Deprecated. instead use sourceDirectories
suppressionsFile String - Deprecated. Use suppressionsLocation instead.
suppressionsFileExpression String 2.1 The key to be used in the properties for the suppressions file.
Default value is: checkstyle.suppressions.file.
User property is: checkstyle.suppression.expression.
suppressionsLocation String 2.0-beta-2

Specifies the location of the suppressions XML file to use.

This parameter is resolved as resource, URL, then file. If successfully resolved, the contents of the suppressions XML is copied into the ${project.build.directory}/checkstyle-supressions.xml file before being passed to Checkstyle for loading.

See suppressionsFileExpression for the property that will be made available to your Checkstyle configuration.


User property is: checkstyle.suppressions.location.
testSourceDirectories List 2.13 Specifies the location of the test source directories to be used for Checkstyle.
Default value is: ${project.testCompileSourceRoots}.
testSourceDirectory File 2.2 Deprecated. instead use testSourceDirectories
treeWalkerNames List 2.11 When using custom treeWalkers, specify their names here so the checks inside the treeWalker end up the the rule-summary.
useFile File - If null, the Checkstyle plugin will display violations on stdout. Otherwise, a text file will be created with the violations.
xrefLocation File - Location of the Xrefs to link to.
Default value is: ${project.reporting.outputDirectory}/xref.

Parameter Details

cacheFile:

Specifies the cache file used to speed up Checkstyle on successive runs.
  • Type: java.lang.String
  • Required: No
  • Default: ${project.build.directory}/checkstyle-cachefile

configLocation:

Specifies the location of the XML configuration to use.

Potential values are a filesystem path, a URL, or a classpath resource. This parameter expects that the contents of the location conform to the xml format (Checkstyle Checker module) configuration of rulesets.

This parameter is resolved as resource, URL, then file. If successfully resolved, the contents of the configuration is copied into the ${project.build.directory}/checkstyle-configuration.xml file before being passed to Checkstyle as a configuration.

There are 2 predefined rulesets included in Maven Checkstyle Plugin:

  • sun_checks.xml: Sun Checks.
  • google_checks.xml: Google Checks.
  • Type: java.lang.String
  • Required: No
  • User Property: checkstyle.config.location
  • Default: sun_checks.xml

consoleOutput:

Output errors to console.
  • Type: boolean
  • Required: No
  • User Property: checkstyle.consoleOutput
  • Default: false

enableFilesSummary:

Specifies if the Files summary should be enabled or not.
  • Type: boolean
  • Required: No
  • User Property: checkstyle.enable.files.summary
  • Default: true

enableRSS:

Specifies if the RSS should be enabled or not.
  • Type: boolean
  • Required: No
  • User Property: checkstyle.enable.rss
  • Default: true

enableRulesSummary:

Specifies if the Rules summary should be enabled or not.
  • Type: boolean
  • Required: No
  • User Property: checkstyle.enable.rules.summary
  • Default: true

enableSeveritySummary:

Specifies if the Severity summary should be enabled or not.
  • Type: boolean
  • Required: No
  • User Property: checkstyle.enable.severity.summary
  • Default: true

encoding:

The file encoding to use when reading the source files. If the property project.build.sourceEncoding is not set, the platform default encoding is used. Note: This parameter always overrides the property charset from Checkstyle's TreeWalker module.
  • Type: java.lang.String
  • Since: 2.2
  • Required: No
  • User Property: encoding
  • Default: ${project.build.sourceEncoding}

excludes:

Specifies the names filter of the source files to be excluded for Checkstyle.
  • Type: java.lang.String
  • Required: No
  • User Property: checkstyle.excludes

failsOnError:

Specifies if the build should fail upon a violation.
  • Type: boolean
  • Required: No
  • Default: false

format:

Deprecated. Use configLocation instead.
Specifies what predefined check set to use. Available sets are "sun" (for the Sun coding conventions), and "maven".
  • Type: java.lang.String
  • Required: No
  • Default: sun

headerFile:

Deprecated. Use headerLocation instead.
Specifies the location of the License file (a.k.a. the header file) that is used by Checkstyle to verify that source code has the correct license header.
  • Type: java.io.File
  • Required: No
  • Default: ${basedir}/LICENSE.txt

headerLocation:

Specifies the location of the License file (a.k.a. the header file) that can be used by Checkstyle to verify that source code has the correct license header.

You need to use ${checkstyle.header.file} in your Checkstyle xml configuration to reference the name of this header file.

For instance:

<module name="RegexpHeader"> <property name="headerFile" value="${checkstyle.header.file}"/> </module>

  • Type: java.lang.String
  • Since: 2.0-beta-2
  • Required: No
  • User Property: checkstyle.header.file
  • Default: LICENSE.txt

includeResources:

Specifies whether to include the resource directories in the check.
  • Type: boolean
  • Since: 2.11
  • Required: Yes
  • User Property: checkstyle.includeResources
  • Default: true

includeTestResources:

Specifies whether to include the test resource directories in the check.
  • Type: boolean
  • Since: 2.11
  • Required: Yes
  • User Property: checkstyle.includeTestResources
  • Default: true

includeTestSourceDirectory:

Include or not the test source directory/directories to be used for Checkstyle.
  • Type: boolean
  • Since: 2.2
  • Required: No
  • Default: false

includes:

Specifies the names filter of the source files to be used for Checkstyle.
  • Type: java.lang.String
  • Required: Yes
  • User Property: checkstyle.includes
  • Default: **\/*.java

linkXRef:

Link the violation line numbers to the source xref. Will link automatically if Maven JXR plugin is being used.
  • Type: boolean
  • Since: 2.1
  • Required: No
  • User Property: linkXRef
  • Default: true

outputFile:

Specifies the path and filename to save the Checkstyle output. The format of the output file is determined by the outputFileFormat parameter.
  • Type: java.io.File
  • Required: No
  • User Property: checkstyle.output.file
  • Default: ${project.build.directory}/checkstyle-result.xml

outputFileFormat:

Specifies the format of the output to be used when writing to the output file. Valid values are "plain" and "xml".
  • Type: java.lang.String
  • Required: No
  • User Property: checkstyle.output.format
  • Default: xml

packageNamesFile:

Deprecated. Use packageNamesLocation instead.
Specifies the location of the package names XML to be used to configure Checkstyle.
  • Type: java.lang.String
  • Required: No

packageNamesLocation:

Specifies the location of the package names XML to be used to configure the Checkstyle Packages.

This parameter is resolved as resource, URL, then file. If resolved to a resource, or a URL, the contents of the package names XML is copied into the ${project.build.directory}/checkstyle-packagenames.xml file before being passed to Checkstyle for loading.

  • Type: java.lang.String
  • Since: 2.0-beta-2
  • Required: No

propertiesFile:

Deprecated. Use propertiesLocation instead.
Specifies the location of the Checkstyle properties file that will be used to check the source.
  • Type: java.io.File
  • Required: No

propertiesLocation:

Specifies the location of the properties file.

This parameter is resolved as URL, File then resource. If successfully resolved, the contents of the properties location is copied into the ${project.build.directory}/checkstyle-checker.properties file before being passed to Checkstyle for loading.

The contents of the propertiesLocation will be made available to Checkstyle for specifying values for parameters within the xml configuration (specified in the configLocation parameter).

  • Type: java.lang.String
  • Since: 2.0-beta-2
  • Required: No
  • User Property: checkstyle.properties.location

propertiesURL:

Deprecated. Use propertiesLocation instead.
Specifies the URL of the Checkstyle properties that will be used to check the source.
  • Type: java.net.URL
  • Required: No

propertyExpansion:

Allows for specifying raw property expansion information.
  • Type: java.lang.String
  • Required: No

resourceExcludes:

Specifies the names filter of the resource files to be excluded for Checkstyle.
  • Type: java.lang.String
  • Since: 2.11
  • Required: No
  • User Property: checkstyle.resourceExcludes

resourceIncludes:

Specifies the names filter of the resource files to be used for Checkstyle.
  • Type: java.lang.String
  • Since: 2.11
  • Required: Yes
  • User Property: checkstyle.resourceIncludes
  • Default: **/*.properties

skip:

Skip entire check.
  • Type: boolean
  • Since: 2.2
  • Required: No
  • User Property: checkstyle.skip
  • Default: false

sourceDirectories:

Specifies the location of the source directories to be used for Checkstyle.
  • Type: java.util.List
  • Since: 2.13
  • Required: No
  • Default: ${project.compileSourceRoots}

sourceDirectory:

Deprecated. instead use sourceDirectories
Specifies the location of the source directory to be used for Checkstyle.
  • Type: java.io.File
  • Required: No

suppressionsFile:

Deprecated. Use suppressionsLocation instead.
Specifies the location of the suppressions XML file to use. The plugin defines a Checkstyle property named checkstyle.suppressions.file with the value of this property. This allows using the Checkstyle property in your own custom Checkstyle configuration file when specifying a suppressions file.
  • Type: java.lang.String
  • Required: No

suppressionsFileExpression:

The key to be used in the properties for the suppressions file.
  • Type: java.lang.String
  • Since: 2.1
  • Required: No
  • User Property: checkstyle.suppression.expression
  • Default: checkstyle.suppressions.file

suppressionsLocation:

Specifies the location of the suppressions XML file to use.

This parameter is resolved as resource, URL, then file. If successfully resolved, the contents of the suppressions XML is copied into the ${project.build.directory}/checkstyle-supressions.xml file before being passed to Checkstyle for loading.

See suppressionsFileExpression for the property that will be made available to your Checkstyle configuration.

  • Type: java.lang.String
  • Since: 2.0-beta-2
  • Required: No
  • User Property: checkstyle.suppressions.location

testSourceDirectories:

Specifies the location of the test source directories to be used for Checkstyle.
  • Type: java.util.List
  • Since: 2.13
  • Required: No
  • Default: ${project.testCompileSourceRoots}

testSourceDirectory:

Deprecated. instead use testSourceDirectories
Specifies the location of the test source directory to be used for Checkstyle.
  • Type: java.io.File
  • Since: 2.2
  • Required: No

treeWalkerNames:

When using custom treeWalkers, specify their names here so the checks inside the treeWalker end up the the rule-summary.
  • Type: java.util.List
  • Since: 2.11
  • Required: No

useFile:

If null, the Checkstyle plugin will display violations on stdout. Otherwise, a text file will be created with the violations.
  • Type: java.io.File
  • Required: No

xrefLocation:

Location of the Xrefs to link to.
  • Type: java.io.File
  • Required: No
  • Default: ${project.reporting.outputDirectory}/xref