Class AbstractCheckstyleReport
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
,org.apache.maven.reporting.MavenMultiPageReport
,org.apache.maven.reporting.MavenReport
- Direct Known Subclasses:
CheckstyleAggregateReport
,CheckstyleReport
- Version:
- $Id$
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
Specifies the cache file used to speed up Checkstyle on successive runs.protected CheckstyleExecutor
protected CheckstyleRssGenerator
CheckstyleRssGenerator.protected String
Specifies the location of the XML configuration to use.protected boolean
Output errors to console.private boolean
Specifies if the Files summary should be enabled or not.private boolean
Specifies if the RSS should be enabled or not.private boolean
Specifies if the Rules summary should be enabled or not.private boolean
Specifies if the Severity summary should be enabled or not.protected String
The file encoding to use when reading the source files.protected String
Specifies the names filter of the source files to be excluded for Checkstyle.protected boolean
Specifies if the build should fail upon a violation.protected String
Specifies the location of the License file (a.k.a.protected boolean
Specifies whether to include the resource directories in the check.protected String
Specifies the names filter of the source files to be used for Checkstyle.protected boolean
Specifies whether to include the test resource directories in the check.protected boolean
Include or not the test source directory/directories to be used for Checkstyle.protected static final String
private boolean
Link the violation line numbers to the source xref.protected org.codehaus.plexus.resource.ResourceManager
private boolean
Specifies whether modules with a configured severity ofignore
should be omitted during Checkstyle invocation.private File
Specifies the path and filename to save the Checkstyle output.private String
Specifies the format of the output to be used when writing to the output file.private org.apache.maven.plugin.descriptor.PluginDescriptor
The Plugin Descriptorstatic final String
protected String
Specifies the location of the properties file.protected String
Allows for specifying raw property expansion information.protected String
Specifies the names filter of the resource files to be excluded for Checkstyle.protected String
Specifies the names filter of the resource files to be used for Checkstyle.protected List<org.apache.maven.model.Resource>
Specifies the location of the resources to be used for Checkstyle.protected org.apache.maven.doxia.tools.SiteTool
SiteTool.protected boolean
Skip entire check.Specifies the location of the source directories to be used for Checkstyle.private File
Deprecated.protected ByteArrayOutputStream
protected String
The key to be used in the properties for the suppressions file.protected String
Specifies the location of the suppressions XML file to use.protected List<org.apache.maven.model.Resource>
Specifies the location of the test resources to be used for Checkstyle.Specifies the location of the test source directories to be used for Checkstyle.private File
Deprecated.instead usetestSourceDirectories
.When using custom treeWalkers, specify their names here so the checks inside the treeWalker end up the the rule-summary.private File
Ifnull
, the Checkstyle plugin will display violations on stdout.private File
Location of the Xrefs to link to.Fields inherited from class org.apache.maven.reporting.AbstractMavenReport
outputDirectory, project, siteRenderer
Fields inherited from interface org.apache.maven.reporting.MavenReport
CATEGORY_PROJECT_INFORMATION, CATEGORY_PROJECT_REPORTS, ROLE
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
checkDeprecatedParameterUsage
(Object parameter, String name, String replacement) private List<org.apache.maven.artifact.Artifact>
collectArtifacts
(String hint) protected abstract CheckstyleExecutorRequest
Create the Checkstyle executor request.void
executeReport
(Locale locale) private void
generateMainReport
(CheckstyleResults results, ResourceBundle bundle) private void
private static ResourceBundle
private List<org.apache.maven.artifact.Artifact>
getCheckstylePluginDependenciesAsArtifacts
(Map<String, org.apache.maven.model.Plugin> plugins, String hint) protected com.puppycrawl.tools.checkstyle.DefaultLogger
Creates and returns the console listener.private String
getDescription
(Locale locale) protected com.puppycrawl.tools.checkstyle.api.AuditListener
Creates and returns the report generation listener.private OutputStream
getOutputStream
(File file) Methods inherited from class org.apache.maven.reporting.AbstractMavenReport
canGenerateReport, closeReport, execute, generate, generate, generate, getCategoryName, getInputEncoding, getOutputDirectory, getOutputEncoding, getProject, getReportOutputDirectory, getSink, getSinkFactory, getSiteRenderer, isExternalReport, setReportOutputDirectory
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.maven.reporting.MavenReport
getOutputName
-
Field Details
-
PLUGIN_RESOURCES
- See Also:
-
JAVA_FILES
- See Also:
-
cacheFile
@Parameter(defaultValue="${project.build.directory}/checkstyle-cachefile") protected String cacheFileSpecifies the cache file used to speed up Checkstyle on successive runs. -
configLocation
@Parameter(property="checkstyle.config.location", defaultValue="sun_checks.xml") protected String configLocationSpecifies 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.
-
consoleOutput
@Parameter(property="checkstyle.consoleOutput", defaultValue="false") protected boolean consoleOutputOutput errors to console. -
encoding
@Parameter(property="encoding", defaultValue="${project.build.sourceEncoding}") protected String encodingThe file encoding to use when reading the source files. If the propertyproject.build.sourceEncoding
is not set, the platform default encoding is used. Note: This parameter always overrides the propertycharset
from Checkstyle'sTreeWalker
module.- Since:
- 2.2
-
failsOnError
@Parameter(defaultValue="false") protected boolean failsOnErrorSpecifies if the build should fail upon a violation. -
headerLocation
@Parameter(property="checkstyle.header.file", defaultValue="LICENSE.txt") protected String headerLocationSpecifies 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>
- Since:
- 2.0-beta-2
-
skip
@Parameter(property="checkstyle.skip", defaultValue="false") protected boolean skipSkip entire check.- Since:
- 2.2
-
outputFile
@Parameter(property="checkstyle.output.file", defaultValue="${project.build.directory}/checkstyle-result.xml") private File outputFileSpecifies the path and filename to save the Checkstyle output. The format of the output file is determined by theoutputFileFormat
parameter. -
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 theconfigLocation
parameter).- Since:
- 2.0-beta-2
-
propertyExpansion
Allows for specifying raw property expansion information. -
resources
@Parameter(defaultValue="${project.resources}", readonly=true) protected List<org.apache.maven.model.Resource> resourcesSpecifies the location of the resources to be used for Checkstyle.- Since:
- 2.10
-
testResources
@Parameter(defaultValue="${project.testResources}", readonly=true) protected List<org.apache.maven.model.Resource> testResourcesSpecifies the location of the test resources to be used for Checkstyle.- Since:
- 2.11
-
includes
@Parameter(property="checkstyle.includes", defaultValue="**\\/*.java", required=true) protected String includesSpecifies the names filter of the source files to be used for Checkstyle. -
excludes
Specifies the names filter of the source files to be excluded for Checkstyle. -
resourceIncludes
@Parameter(property="checkstyle.resourceIncludes", defaultValue="**/*.properties", required=true) protected String resourceIncludesSpecifies the names filter of the resource files to be used for Checkstyle.- Since:
- 2.11
-
resourceExcludes
Specifies the names filter of the resource files to be excluded for Checkstyle.- Since:
- 2.11
-
includeResources
@Parameter(property="checkstyle.includeResources", defaultValue="true", required=true) protected boolean includeResourcesSpecifies whether to include the resource directories in the check.- Since:
- 2.11
-
includeTestResources
@Parameter(property="checkstyle.includeTestResources", defaultValue="true", required=true) protected boolean includeTestResourcesSpecifies whether to include the test resource directories in the check.- Since:
- 2.11
-
sourceDirectory
Deprecated.instead usesourceDirectories
. For version 3.0.0, this parameter is only defined to break the build if you use it!Specifies the location of the source directory to be used for Checkstyle. -
sourceDirectories
Specifies the location of the source directories to be used for Checkstyle. Default value is${project.compileSourceRoots}
.- Since:
- 2.13
-
testSourceDirectory
Deprecated.instead usetestSourceDirectories
. For version 3.0.0, this parameter is only defined to break the build if you use it!Specifies the location of the test source directory to be used for Checkstyle.- Since:
- 2.2
-
testSourceDirectories
Specifies the location of the test source directories to be used for Checkstyle. Default value is${project.testCompileSourceRoots}
.- Since:
- 2.13
-
includeTestSourceDirectory
@Parameter(defaultValue="false") protected boolean includeTestSourceDirectoryInclude or not the test source directory/directories to be used for Checkstyle.- Since:
- 2.2
-
suppressionsFileExpression
@Parameter(property="checkstyle.suppression.expression", defaultValue="checkstyle.suppressions.file") protected String suppressionsFileExpressionThe key to be used in the properties for the suppressions file.- Since:
- 2.1
-
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.- Since:
- 2.0-beta-2
-
useFile
Ifnull
, the Checkstyle plugin will display violations on stdout. Otherwise, a text file will be created with the violations. -
outputFileFormat
Specifies the format of the output to be used when writing to the output file. Valid values are "plain
" and "xml
". -
enableRulesSummary
@Parameter(property="checkstyle.enable.rules.summary", defaultValue="true") private boolean enableRulesSummarySpecifies if the Rules summary should be enabled or not. -
enableSeveritySummary
@Parameter(property="checkstyle.enable.severity.summary", defaultValue="true") private boolean enableSeveritySummarySpecifies if the Severity summary should be enabled or not. -
enableFilesSummary
@Parameter(property="checkstyle.enable.files.summary", defaultValue="true") private boolean enableFilesSummarySpecifies if the Files summary should be enabled or not. -
enableRSS
@Parameter(property="checkstyle.enable.rss", defaultValue="true") private boolean enableRSSSpecifies if the RSS should be enabled or not. -
siteTool
@Component(role=org.apache.maven.doxia.tools.SiteTool.class) protected org.apache.maven.doxia.tools.SiteTool siteToolSiteTool.- Since:
- 2.2
-
plugin
@Parameter(defaultValue="${plugin}", readonly=true, required=true) private org.apache.maven.plugin.descriptor.PluginDescriptor pluginThe Plugin Descriptor -
linkXRef
@Parameter(property="linkXRef", defaultValue="true") private boolean linkXRefLink the violation line numbers to the source xref. Will link automatically if Maven JXR plugin is being used.- Since:
- 2.1
-
xrefLocation
Location of the Xrefs to link to. -
treeWalkerNames
When using custom treeWalkers, specify their names here so the checks inside the treeWalker end up the the rule-summary.- Since:
- 2.11
-
omitIgnoredModules
@Parameter(defaultValue="false") private boolean omitIgnoredModulesSpecifies whether modules with a configured severity ofignore
should be omitted during Checkstyle invocation.- Since:
- 3.0.0
-
locator
@Component protected org.codehaus.plexus.resource.ResourceManager locator -
checkstyleRssGenerator
@Component(role=CheckstyleRssGenerator.class, hint="default") protected CheckstyleRssGenerator checkstyleRssGeneratorCheckstyleRssGenerator.- Since:
- 2.4
-
checkstyleExecutor
@Component(role=CheckstyleExecutor.class, hint="default") protected CheckstyleExecutor checkstyleExecutor- Since:
- 2.5
-
stringOutputStream
-
-
Constructor Details
-
AbstractCheckstyleReport
public AbstractCheckstyleReport()
-
-
Method Details
-
getName
-
getDescription
-
executeReport
- Specified by:
executeReport
in classorg.apache.maven.reporting.AbstractMavenReport
- Throws:
org.apache.maven.reporting.MavenReportException
-
checkDeprecatedParameterUsage
private void checkDeprecatedParameterUsage(Object parameter, String name, String replacement) throws org.apache.maven.reporting.MavenReportException - Throws:
org.apache.maven.reporting.MavenReportException
-
createRequest
protected abstract CheckstyleExecutorRequest createRequest() throws org.apache.maven.reporting.MavenReportExceptionCreate the Checkstyle executor request.- Returns:
- The executor request.
- Throws:
org.apache.maven.reporting.MavenReportException
- If something goes wrong during creation.
-
collectArtifacts
-
getCheckstylePluginDependenciesAsArtifacts
-
getListener
protected com.puppycrawl.tools.checkstyle.api.AuditListener getListener() throws org.apache.maven.reporting.MavenReportExceptionCreates and returns the report generation listener.- Returns:
- The audit listener.
- Throws:
org.apache.maven.reporting.MavenReportException
- If something goes wrong.
-
getOutputStream
private OutputStream getOutputStream(File file) throws org.apache.maven.reporting.MavenReportException - Throws:
org.apache.maven.reporting.MavenReportException
-
getConsoleListener
protected com.puppycrawl.tools.checkstyle.DefaultLogger getConsoleListener() throws org.apache.maven.reporting.MavenReportExceptionCreates and returns the console listener.- Returns:
- The console listener.
- Throws:
org.apache.maven.reporting.MavenReportException
- If something goes wrong.
-
generateReportStatics
private void generateReportStatics() throws org.apache.maven.reporting.MavenReportException- Throws:
org.apache.maven.reporting.MavenReportException
-
getCopyright
-
generateMainReport
-
getBundle
-
getSourceDirectories
-
getTestSourceDirectories
-
sourceDirectories
.