org.apache.maven.plugin.checkstyle
Class AbstractCheckstyleReport

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.apache.maven.reporting.AbstractMavenReport
          extended by org.apache.maven.plugin.checkstyle.AbstractCheckstyleReport
All Implemented Interfaces:
ContextEnabled, Mojo, MavenMultiPageReport, MavenReport
Direct Known Subclasses:
CheckstyleAggregateReport, CheckstyleReport

public abstract class AbstractCheckstyleReport
extends AbstractMavenReport

Base abstract class for Checkstyle reports.

Since:
2.8
Version:
$Id: AbstractCheckstyleReport.java 1586844 2014-04-12 09:53:39Z rfscholte $

Field Summary
protected  String cacheFile
          Specifies the cache file used to speed up Checkstyle on successive runs.
protected  CheckstyleExecutor checkstyleExecutor
           
protected  CheckstyleRssGenerator checkstyleRssGenerator
          CheckstyleRssGenerator.
protected  String configLocation
           Specifies the location of the XML configuration to use.
protected  boolean consoleOutput
          Output errors to console.
protected  String encoding
          The file encoding to use when reading the source files.
protected  String excludes
          Specifies the names filter of the source files to be excluded for Checkstyle.
protected  boolean failsOnError
          Specifies if the build should fail upon a violation.
protected  String 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.
protected  boolean includeResources
          Specifies whether to include the resource directories in the check.
protected  String includes
          Specifies the names filter of the source files to be used for Checkstyle.
protected  boolean includeTestResources
          Specifies whether to include the test resource directories in the check.
protected  boolean includeTestSourceDirectory
          Include or not the test source directory to be used for Checkstyle.
protected static String JAVA_FILES
           
protected  ResourceManager locator
           
static String PLUGIN_RESOURCES
           
protected  MavenProject project
          The Maven Project Object.
protected  String propertiesLocation
           Specifies the location of the properties file.
protected  String propertyExpansion
          Allows for specifying raw property expansion information.
protected  String resourceExcludes
          Specifies the names filter of the resource files to be excluded for Checkstyle.
protected  String resourceIncludes
          Specifies the names filter of the resource files to be used for Checkstyle.
protected  List<Resource> resources
          Specifies the location of the resources to be used for Checkstyle.
protected  SiteTool siteTool
          SiteTool.
protected  boolean skip
          Skip entire check.
protected  File sourceDirectory
          Specifies the location of the source directory to be used for Checkstyle.
protected  ByteArrayOutputStream stringOutputStream
           
protected  String suppressionsFileExpression
          The key to be used in the properties for the suppressions file.
protected  String suppressionsLocation
           Specifies the location of the suppressions XML file to use.
protected  List<Resource> testResources
          Specifies the location of the test resources to be used for Checkstyle.
protected  File testSourceDirectory
          Specifies the location of the test source directory to be used for Checkstyle.
 
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
AbstractCheckstyleReport()
           
 
Method Summary
protected abstract  CheckstyleExecutorRequest createRequest()
          Create the Checkstyle executor request.
 void executeReport(Locale locale)
          
protected  DefaultLogger getConsoleListener()
          Creates and returns the console listener.
 String getDescription(Locale locale)
          
protected  AuditListener getListener()
          Creates and returns the report generation listener.
 String getName(Locale locale)
          
protected  String getOutputDirectory()
          
protected  MavenProject getProject()
          
protected  Renderer getSiteRenderer()
          
 void setReportOutputDirectory(File reportOutputDirectory)
          
 
Methods inherited from class org.apache.maven.reporting.AbstractMavenReport
canGenerateReport, closeReport, execute, generate, generate, generate, getCategoryName, getReportOutputDirectory, getSink, getSinkFactory, isExternalReport
 
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 Detail

PLUGIN_RESOURCES

public static final String PLUGIN_RESOURCES
See Also:
Constant Field Values

JAVA_FILES

protected static final String JAVA_FILES
See Also:
Constant Field Values

cacheFile

@Parameter(defaultValue="${project.build.directory}/checkstyle-cachefile")
protected String cacheFile
Specifies the cache file used to speed up Checkstyle on successive runs.


configLocation

@Parameter(property="checkstyle.config.location",
           defaultValue="config/sun_checks.xml")
protected String 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 4 predefined rulesets.


consoleOutput

@Parameter(property="checkstyle.consoleOutput",
           defaultValue="false")
protected boolean consoleOutput
Output errors to console.


encoding

@Parameter(property="encoding",
           defaultValue="${project.build.sourceEncoding}")
protected String 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.

Since:
2.2

failsOnError

@Parameter(defaultValue="false")
protected boolean failsOnError
Specifies if the build should fail upon a violation.


headerLocation

@Parameter(property="checkstyle.header.file",
           defaultValue="LICENSE.txt")
protected String 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>

Since:
2.0-beta-2

skip

@Parameter(property="checkstyle.skip",
           defaultValue="false")
protected boolean skip
Skip entire check.

Since:
2.2

propertiesLocation

@Parameter(property="checkstyle.properties.location")
protected String 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).

Since:
2.0-beta-2

propertyExpansion

@Parameter
protected String propertyExpansion
Allows for specifying raw property expansion information.


resources

@Parameter(defaultValue="${project.resources}",
           readonly=true)
protected List<Resource> resources
Specifies the location of the resources to be used for Checkstyle.

Since:
2.10

testResources

@Parameter(defaultValue="${project.testResources}",
           readonly=true)
protected List<Resource> testResources
Specifies 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 includes
Specifies the names filter of the source files to be used for Checkstyle.


excludes

@Parameter(property="checkstyle.excludes")
protected String 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 resourceIncludes
Specifies the names filter of the resource files to be used for Checkstyle.

Since:
2.11

resourceExcludes

@Parameter(property="checkstyle.resourceExcludes")
protected String 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 includeResources
Specifies whether to include the resource directories in the check.

Since:
2.11

includeTestResources

@Parameter(property="checkstyle.includeTestResources",
           defaultValue="true",
           required=true)
protected boolean includeTestResources
Specifies whether to include the test resource directories in the check.

Since:
2.11

sourceDirectory

@Parameter(defaultValue="${project.build.sourceDirectory}",
           required=true)
protected File sourceDirectory
Specifies the location of the source directory to be used for Checkstyle.


testSourceDirectory

@Parameter(defaultValue="${project.build.testSourceDirectory}")
protected File testSourceDirectory
Specifies the location of the test source directory to be used for Checkstyle.

Since:
2.2

includeTestSourceDirectory

@Parameter(defaultValue="false")
protected boolean includeTestSourceDirectory
Include or not the test source directory to be used for Checkstyle.

Since:
2.2

suppressionsFileExpression

@Parameter(property="checkstyle.suppression.expression",
           defaultValue="checkstyle.suppressions.file")
protected String suppressionsFileExpression
The key to be used in the properties for the suppressions file.

Since:
2.1

suppressionsLocation

@Parameter(property="checkstyle.suppressions.location")
protected String 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

siteTool

@Component(role=org.apache.maven.doxia.tools.SiteTool.class)
protected SiteTool siteTool
SiteTool.

Since:
2.2

project

@Parameter(defaultValue="${project}")
protected MavenProject project
The Maven Project Object.


locator

@Component
protected ResourceManager locator

checkstyleRssGenerator

@Component(role=CheckstyleRssGenerator.class,
           hint="default")
protected CheckstyleRssGenerator checkstyleRssGenerator
CheckstyleRssGenerator.

Since:
2.4

checkstyleExecutor

@Component(role=CheckstyleExecutor.class,
           hint="default")
protected CheckstyleExecutor checkstyleExecutor
Since:
2.5

stringOutputStream

protected ByteArrayOutputStream stringOutputStream
Constructor Detail

AbstractCheckstyleReport

public AbstractCheckstyleReport()
Method Detail

getName

public String getName(Locale locale)


getDescription

public String getDescription(Locale locale)


getOutputDirectory

protected String getOutputDirectory()

Specified by:
getOutputDirectory in class AbstractMavenReport

getProject

protected MavenProject getProject()

Specified by:
getProject in class AbstractMavenReport

getSiteRenderer

protected Renderer getSiteRenderer()

Specified by:
getSiteRenderer in class AbstractMavenReport

executeReport

public void executeReport(Locale locale)
                   throws MavenReportException

Specified by:
executeReport in class AbstractMavenReport
Throws:
MavenReportException

createRequest

protected abstract CheckstyleExecutorRequest createRequest()
                                                    throws MavenReportException
Create the Checkstyle executor request.

Returns:
The executor request.
Throws:
MavenReportException - If something goes wrong during creation.

getListener

protected AuditListener getListener()
                             throws MavenReportException
Creates and returns the report generation listener.

Returns:
The audit listener.
Throws:
MavenReportException - If something goes wrong.

getConsoleListener

protected DefaultLogger getConsoleListener()
                                    throws MavenReportException
Creates and returns the console listener.

Returns:
The console listener.
Throws:
MavenReportException - If something goes wrong.

setReportOutputDirectory

public void setReportOutputDirectory(File reportOutputDirectory)

Specified by:
setReportOutputDirectory in interface MavenReport
Overrides:
setReportOutputDirectory in class AbstractMavenReport


Copyright © 2005–2014 The Apache Software Foundation. All rights reserved.