You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by de...@apache.org on 2014/03/07 16:04:26 UTC

svn commit: r1575283 - in /maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle: AbstractCheckstyleReport.java CheckstyleAggregateReport.java CheckstyleReport.java

Author: dennisl
Date: Fri Mar  7 15:04:26 2014
New Revision: 1575283

URL: http://svn.apache.org/r1575283
Log:
Refactoring: move common parameters to super class.

Modified:
    maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/AbstractCheckstyleReport.java
    maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleAggregateReport.java
    maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java

Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/AbstractCheckstyleReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/AbstractCheckstyleReport.java?rev=1575283&r1=1575282&r2=1575283&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/AbstractCheckstyleReport.java (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/AbstractCheckstyleReport.java Fri Mar  7 15:04:26 2014
@@ -64,6 +64,94 @@ public abstract class AbstractCheckstyle
     protected static final String JAVA_FILES = "**\\/*.java";
 
     /**
+     * Specifies the cache file used to speed up Checkstyle on successive runs.
+     */
+    @Parameter( defaultValue = "${project.build.directory}/checkstyle-cachefile" )
+    protected String cacheFile;
+
+    /**
+     * <p>
+     * Specifies the location of the XML configuration to use.
+     * </p>
+     * <p/>
+     * <p>
+     * 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 <a
+     * href="http://checkstyle.sourceforge.net/config.html#Modules">Checker
+     * module</a>) configuration of rulesets.
+     * </p>
+     * <p/>
+     * <p>
+     * This parameter is resolved as resource, URL, then file. If successfully
+     * resolved, the contents of the configuration is copied into the
+     * <code>${project.build.directory}/checkstyle-configuration.xml</code>
+     * file before being passed to Checkstyle as a configuration.
+     * </p>
+     * <p/>
+     * <p>
+     * There are 4 predefined rulesets.
+     * </p>
+     * <p/>
+     * <ul>
+     * <li><code>config/sun_checks.xml</code>: Sun Checks.</li>
+     * <li><code>config/turbine_checks.xml</code>: Turbine Checks.</li>
+     * <li><code>config/avalon_checks.xml</code>: Avalon Checks.</li>
+     * <li><code>config/maven_checks.xml</code>: Maven Source Checks.</li>
+     * </ul>
+     */
+    @Parameter( property = "checkstyle.config.location", defaultValue = "config/sun_checks.xml" )
+    protected String configLocation;
+
+    /**
+     * Output errors to console.
+     */
+    @Parameter( property = "checkstyle.consoleOutput", defaultValue = "false" )
+    protected boolean consoleOutput;
+
+    /**
+     * The file encoding to use when reading the source files. If the property <code>project.build.sourceEncoding</code>
+     * is not set, the platform default encoding is used. <strong>Note:</strong> This parameter always overrides the
+     * property <code>charset</code> from Checkstyle's <code>TreeWalker</code> module.
+     *
+     * @since 2.2
+     */
+    @Parameter( property = "encoding", defaultValue = "${project.build.sourceEncoding}" )
+    protected String encoding;
+
+    /**
+     * Specifies if the build should fail upon a violation.
+     */
+    @Parameter( defaultValue = "false" )
+    protected boolean failsOnError;
+
+    /**
+     * <p>
+     * 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.
+     * </p>
+     * <p>
+     * You need to use ${checkstyle.header.file} in your Checkstyle xml
+     * configuration to reference the name of this header file.
+     * </p>
+     * <p>
+     * For instance:
+     * </p>
+     * <p>
+     * <code>
+     * &lt;module name="RegexpHeader">
+     * &lt;property name="headerFile" value="${checkstyle.header.file}"/>
+     * &lt;/module>
+     * </code>
+     * </p>
+     *
+     * @since 2.0-beta-2
+     */
+    @Parameter( property = "checkstyle.header.file", defaultValue = "LICENSE.txt" )
+    protected String headerLocation;
+
+    /**
      * Skip entire check.
      *
      * @since 2.2
@@ -89,6 +177,36 @@ public abstract class AbstractCheckstyle
     private File outputFile;
 
     /**
+     * <p>
+     * Specifies the location of the properties file.
+     * </p>
+     * <p/>
+     * <p>
+     * This parameter is resolved as URL, File then resource. If successfully
+     * resolved, the contents of the properties location is copied into the
+     * <code>${project.build.directory}/checkstyle-checker.properties</code>
+     * file before being passed to Checkstyle for loading.
+     * </p>
+     * <p/>
+     * <p>
+     * The contents of the <code>propertiesLocation</code> will be made
+     * available to Checkstyle for specifying values for parameters within the
+     * xml configuration (specified in the <code>configLocation</code>
+     * parameter).
+     * </p>
+     *
+     * @since 2.0-beta-2
+     */
+    @Parameter( property = "checkstyle.properties.location" )
+    protected String propertiesLocation;
+
+    /**
+     * Allows for specifying raw property expansion information.
+     */
+    @Parameter
+    protected String propertyExpansion;
+
+    /**
      * Specifies the location of the resources to be used for Checkstyle.
      *
      * @since 2.10
@@ -147,6 +265,59 @@ public abstract class AbstractCheckstyle
     protected boolean includeTestResources;
 
     /**
+     * Specifies the location of the source directory to be used for Checkstyle.
+     */
+    @Parameter( defaultValue = "${project.build.sourceDirectory}", required = true )
+    protected File sourceDirectory;
+
+    /**
+     * Specifies the location of the test source directory to be used for
+     * Checkstyle.
+     *
+     * @since 2.2
+     */
+    @Parameter( defaultValue = "${project.build.testSourceDirectory}" )
+    protected File testSourceDirectory;
+
+    /**
+     * Include or not the test source directory to be used for Checkstyle.
+     *
+     * @since 2.2
+     */
+    @Parameter( defaultValue = "false" )
+    protected boolean includeTestSourceDirectory;
+
+    /**
+     * The key to be used in the properties for the suppressions file.
+     *
+     * @since 2.1
+     */
+    @Parameter( property = "checkstyle.suppression.expression", defaultValue = "checkstyle.suppressions.file" )
+    protected String suppressionsFileExpression;
+
+    /**
+     * <p>
+     * Specifies the location of the suppressions XML file to use.
+     * </p>
+     * <p/>
+     * <p>
+     * This parameter is resolved as resource, URL, then file. If successfully
+     * resolved, the contents of the suppressions XML is copied into the
+     * <code>${project.build.directory}/checkstyle-supressions.xml</code> file
+     * before being passed to Checkstyle for loading.
+     * </p>
+     * <p/>
+     * <p>
+     * See <code>suppressionsFileExpression</code> for the property that will
+     * be made available to your checkstyle configuration.
+     * </p>
+     *
+     * @since 2.0-beta-2
+     */
+    @Parameter( property = "checkstyle.suppressions.location" )
+    protected String suppressionsLocation;
+
+    /**
      * If <code>null</code>, the Checkstyle plugin will display violations on stdout.
      * Otherwise, a text file will be created with the violations.
      */

Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleAggregateReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleAggregateReport.java?rev=1575283&r1=1575282&r2=1575283&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleAggregateReport.java (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleAggregateReport.java Fri Mar  7 15:04:26 2014
@@ -40,177 +40,6 @@ public class CheckstyleAggregateReport
     extends AbstractCheckstyleReport
 {
     /**
-     * <p>
-     * Specifies the location of the XML configuration to use.
-     * </p>
-     * <p/>
-     * <p>
-     * 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 <a
-     * href="http://checkstyle.sourceforge.net/config.html#Modules">Checker
-     * module</a>) configuration of rulesets.
-     * </p>
-     * <p/>
-     * <p>
-     * This parameter is resolved as resource, URL, then file. If successfully
-     * resolved, the contents of the configuration is copied into the
-     * <code>${project.build.directory}/checkstyle-configuration.xml</code>
-     * file before being passed to Checkstyle as a configuration.
-     * </p>
-     * <p/>
-     * <p>
-     * There are 4 predefined rulesets.
-     * </p>
-     * <p/>
-     * <ul>
-     * <li><code>config/sun_checks.xml</code>: Sun Checks.</li>
-     * <li><code>config/turbine_checks.xml</code>: Turbine Checks.</li>
-     * <li><code>config/avalon_checks.xml</code>: Avalon Checks.</li>
-     * <li><code>config/maven_checks.xml</code>: Maven Source Checks.</li>
-     * </ul>
-     */
-    @Parameter( property = "checkstyle.config.location", defaultValue = "config/sun_checks.xml" )
-    private String configLocation;
-
-    /**
-     * <p>
-     * Specifies the location of the properties file.
-     * </p>
-     * <p/>
-     * <p>
-     * This parameter is resolved as URL, File then resource. If successfully
-     * resolved, the contents of the properties location is copied into the
-     * <code>${project.build.directory}/checkstyle-checker.properties</code>
-     * file before being passed to Checkstyle for loading.
-     * </p>
-     * <p/>
-     * <p>
-     * The contents of the <code>propertiesLocation</code> will be made
-     * available to Checkstyle for specifying values for parameters within the
-     * xml configuration (specified in the <code>configLocation</code>
-     * parameter).
-     * </p>
-     *
-     * @since 2.0-beta-2
-     */
-    @Parameter( property = "checkstyle.properties.location" )
-    private String propertiesLocation;
-
-    /**
-     * Allows for specifying raw property expansion information.
-     */
-    @Parameter
-    private String propertyExpansion;
-
-    /**
-     * <p>
-     * 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.
-     * </p>
-     * <p>
-     * You need to use ${checkstyle.header.file} in your Checkstyle xml
-     * configuration to reference the name of this header file.
-     * </p>
-     * <p>
-     * For instance:
-     * </p>
-     * <p>
-     * <code>
-     * &lt;module name="RegexpHeader">
-     * &lt;property name="headerFile" value="${checkstyle.header.file}"/>
-     * &lt;/module>
-     * </code>
-     * </p>
-     *
-     * @since 2.0-beta-2
-     */
-    @Parameter( property = "checkstyle.header.file", defaultValue = "LICENSE.txt" )
-    private String headerLocation;
-
-    /**
-     * Specifies the cache file used to speed up Checkstyle on successive runs.
-     */
-    @Parameter( defaultValue = "${project.build.directory}/checkstyle-cachefile" )
-    private String cacheFile;
-
-    /**
-     * <p>
-     * Specifies the location of the suppressions XML file to use.
-     * </p>
-     * <p/>
-     * <p>
-     * This parameter is resolved as resource, URL, then file. If successfully
-     * resolved, the contents of the suppressions XML is copied into the
-     * <code>${project.build.directory}/checkstyle-supressions.xml</code> file
-     * before being passed to Checkstyle for loading.
-     * </p>
-     * <p/>
-     * <p>
-     * See <code>suppressionsFileExpression</code> for the property that will
-     * be made available to your checkstyle configuration.
-     * </p>
-     *
-     * @since 2.0-beta-2
-     */
-    @Parameter( property = "checkstyle.suppressions.location" )
-    private String suppressionsLocation;
-
-    /**
-     * The key to be used in the properties for the suppressions file.
-     *
-     * @since 2.1
-     */
-    @Parameter( property = "checkstyle.suppression.expression", defaultValue = "checkstyle.suppressions.file" )
-    private String suppressionsFileExpression;
-
-    /**
-     * Specifies if the build should fail upon a violation.
-     */
-    @Parameter( defaultValue = "false" )
-    private boolean failsOnError;
-
-    /**
-     * Specifies the location of the source directory to be used for Checkstyle.
-     */
-    @Parameter( defaultValue = "${project.build.sourceDirectory}", required = true )
-    private File sourceDirectory;
-
-    /**
-     * Specifies the location of the test source directory to be used for
-     * Checkstyle.
-     *
-     * @since 2.2
-     */
-    @Parameter( defaultValue = "${project.build.testSourceDirectory}" )
-    private File testSourceDirectory;
-
-    /**
-     * Include or not the test source directory to be used for Checkstyle.
-     *
-     * @since 2.2
-     */
-    @Parameter( defaultValue = "false" )
-    private boolean includeTestSourceDirectory;
-
-    /**
-     * Output errors to console.
-     */
-    @Parameter( property = "checkstyle.consoleOutput", defaultValue = "false" )
-    private boolean consoleOutput;
-
-    /**
-     * The file encoding to use when reading the source files. If the property <code>project.build.sourceEncoding</code>
-     * is not set, the platform default encoding is used. <strong>Note:</strong> This parameter always overrides the
-     * property <code>charset</code> from Checkstyle's <code>TreeWalker</code> module.
-     *
-     * @since 2.2
-     */
-    @Parameter( property = "encoding", defaultValue = "${project.build.sourceEncoding}" )
-    private String encoding;
-
-    /**
      * The projects in the reactor for aggregation report.
      *
      * @since 2.8

Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java?rev=1575283&r1=1575282&r2=1575283&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java Fri Mar  7 15:04:26 2014
@@ -63,40 +63,6 @@ public class CheckstyleReport
     }
 
     /**
-     * <p>
-     * Specifies the location of the XML configuration to use.
-     * </p>
-     * <p/>
-     * <p>
-     * 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 <a
-     * href="http://checkstyle.sourceforge.net/config.html#Modules">Checker
-     * module</a>) configuration of rulesets.
-     * </p>
-     * <p/>
-     * <p>
-     * This parameter is resolved as resource, URL, then file. If successfully
-     * resolved, the contents of the configuration is copied into the
-     * <code>${project.build.directory}/checkstyle-configuration.xml</code>
-     * file before being passed to Checkstyle as a configuration.
-     * </p>
-     * <p/>
-     * <p>
-     * There are 4 predefined rulesets.
-     * </p>
-     * <p/>
-     * <ul>
-     * <li><code>config/sun_checks.xml</code>: Sun Checks.</li>
-     * <li><code>config/turbine_checks.xml</code>: Turbine Checks.</li>
-     * <li><code>config/avalon_checks.xml</code>: Avalon Checks.</li>
-     * <li><code>config/maven_checks.xml</code>: Maven Source Checks.</li>
-     * </ul>
-     */
-    @Parameter( property = "checkstyle.config.location", defaultValue = "config/sun_checks.xml" )
-    private String configLocation;
-
-    /**
      * Specifies what predefined check set to use. Available sets are "sun" (for
      * the Sun coding conventions), "turbine", and "avalon".
      *
@@ -106,30 +72,6 @@ public class CheckstyleReport
     private String format;
 
     /**
-     * <p>
-     * Specifies the location of the properties file.
-     * </p>
-     * <p/>
-     * <p>
-     * This parameter is resolved as URL, File then resource. If successfully
-     * resolved, the contents of the properties location is copied into the
-     * <code>${project.build.directory}/checkstyle-checker.properties</code>
-     * file before being passed to Checkstyle for loading.
-     * </p>
-     * <p/>
-     * <p>
-     * The contents of the <code>propertiesLocation</code> will be made
-     * available to Checkstyle for specifying values for parameters within the
-     * xml configuration (specified in the <code>configLocation</code>
-     * parameter).
-     * </p>
-     *
-     * @since 2.0-beta-2
-     */
-    @Parameter( property = "checkstyle.properties.location" )
-    private String propertiesLocation;
-
-    /**
      * Specifies the location of the Checkstyle properties file that will be used to
      * check the source.
      *
@@ -148,38 +90,6 @@ public class CheckstyleReport
     private URL propertiesURL;
 
     /**
-     * Allows for specifying raw property expansion information.
-     */
-    @Parameter
-    private String propertyExpansion;
-
-    /**
-     * <p>
-     * 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.
-     * </p>
-     * <p>
-     * You need to use ${checkstyle.header.file} in your Checkstyle xml
-     * configuration to reference the name of this header file.
-     * </p>
-     * <p>
-     * For instance:
-     * </p>
-     * <p>
-     * <code>
-     * &lt;module name="RegexpHeader">
-     * &lt;property name="headerFile" value="${checkstyle.header.file}"/>
-     * &lt;/module>
-     * </code>
-     * </p>
-     *
-     * @since 2.0-beta-2
-     */
-    @Parameter( property = "checkstyle.header.file", defaultValue = "LICENSE.txt" )
-    private String headerLocation;
-
-    /**
      * 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.
@@ -190,42 +100,6 @@ public class CheckstyleReport
     private File headerFile;
 
     /**
-     * Specifies the cache file used to speed up Checkstyle on successive runs.
-     */
-    @Parameter( defaultValue = "${project.build.directory}/checkstyle-cachefile" )
-    private String cacheFile;
-
-    /**
-     * <p>
-     * Specifies the location of the suppressions XML file to use.
-     * </p>
-     * <p/>
-     * <p>
-     * This parameter is resolved as resource, URL, then file. If successfully
-     * resolved, the contents of the suppressions XML is copied into the
-     * <code>${project.build.directory}/checkstyle-supressions.xml</code> file
-     * before being passed to Checkstyle for loading.
-     * </p>
-     * <p/>
-     * <p>
-     * See <code>suppressionsFileExpression</code> for the property that will
-     * be made available to your checkstyle configuration.
-     * </p>
-     *
-     * @since 2.0-beta-2
-     */
-    @Parameter( property = "checkstyle.suppressions.location" )
-    private String suppressionsLocation;
-
-    /**
-     * The key to be used in the properties for the suppressions file.
-     *
-     * @since 2.1
-     */
-    @Parameter( property = "checkstyle.suppression.expression", defaultValue = "checkstyle.suppressions.file" )
-    private String suppressionsFileExpression;
-
-    /**
      * Specifies the location of the suppressions XML file to use. The plugin
      * defines a Checkstyle property named
      * <code>checkstyle.suppressions.file</code> with the value of this
@@ -265,51 +139,6 @@ public class CheckstyleReport
     @Parameter
     private String packageNamesFile;
 
-    /**
-     * Specifies if the build should fail upon a violation.
-     */
-    @Parameter( defaultValue = "false" )
-    private boolean failsOnError;
-
-    /**
-     * Specifies the location of the source directory to be used for Checkstyle.
-     */
-    @Parameter( defaultValue = "${project.build.sourceDirectory}", required = true )
-    private File sourceDirectory;
-
-    /**
-     * Specifies the location of the test source directory to be used for
-     * Checkstyle.
-     *
-     * @since 2.2
-     */
-    @Parameter( defaultValue = "${project.build.testSourceDirectory}" )
-    private File testSourceDirectory;
-
-    /**
-     * Include or not the test source directory to be used for Checkstyle.
-     *
-     * @since 2.2
-     */
-    @Parameter( defaultValue = "false" )
-    private boolean includeTestSourceDirectory;
-
-    /**
-     * Output errors to console.
-     */
-    @Parameter( property = "checkstyle.consoleOutput", defaultValue = "false" )
-    private boolean consoleOutput;
-
-    /**
-     * The file encoding to use when reading the source files. If the property <code>project.build.sourceEncoding</code>
-     * is not set, the platform default encoding is used. <strong>Note:</strong> This parameter always overrides the
-     * property <code>charset</code> from Checkstyle's <code>TreeWalker</code> module.
-     *
-     * @since 2.2
-     */
-    @Parameter( property = "encoding", defaultValue = "${project.build.sourceEncoding}" )
-    private String encoding;
-
     /** {@inheritDoc} */
     protected MavenProject getProject()
     {