You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by tc...@apache.org on 2012/07/11 11:51:33 UTC
svn commit: r1360089 - in /maven/plugins/trunk/maven-checkstyle-plugin: ./
src/main/java/org/apache/maven/plugin/checkstyle/
Author: tchemit
Date: Wed Jul 11 09:51:32 2012
New Revision: 1360089
URL: http://svn.apache.org/viewvc?rev=1360089&view=rev
Log:
[MCHECKSTYLE-178] use maven-plugin-tools' java 5 annotations
Modified:
maven/plugins/trunk/maven-checkstyle-plugin/pom.xml
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
maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java
Modified: maven/plugins/trunk/maven-checkstyle-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/pom.xml?rev=1360089&r1=1360088&r2=1360089&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/pom.xml Wed Jul 11 09:51:32 2012
@@ -87,6 +87,11 @@ under the License.
<artifactId>maven-project</artifactId>
<version>${mavenVersion}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>3.1</version>
+ </dependency>
<!-- shared -->
<dependency>
@@ -220,6 +225,13 @@ under the License.
<pluginManagement>
<plugins>
<plugin>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+ </configuration>
+ </plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>${sitePluginVersion}</version>
@@ -238,6 +250,17 @@ under the License.
</execution>
</executions>
</plugin>
+ <plugin>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-descriptor</id>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
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=1360089&r1=1360088&r2=1360089&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 Wed Jul 11 09:51:32 2012
@@ -19,22 +19,17 @@ package org.apache.maven.plugin.checksty
* under the License.
*/
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Calendar;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
+import com.puppycrawl.tools.checkstyle.DefaultLogger;
+import com.puppycrawl.tools.checkstyle.XMLLogger;
+import com.puppycrawl.tools.checkstyle.api.AuditListener;
+import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
import org.apache.maven.doxia.siterenderer.Renderer;
import org.apache.maven.doxia.tools.SiteTool;
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.plugin.checkstyle.rss.CheckstyleRssGenerator;
import org.apache.maven.plugin.checkstyle.rss.CheckstyleRssGeneratorRequest;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.AbstractMavenReport;
import org.apache.maven.reporting.MavenReportException;
@@ -43,15 +38,21 @@ import org.codehaus.plexus.resource.load
import org.codehaus.plexus.util.PathTool;
import org.codehaus.plexus.util.StringUtils;
-import com.puppycrawl.tools.checkstyle.DefaultLogger;
-import com.puppycrawl.tools.checkstyle.XMLLogger;
-import com.puppycrawl.tools.checkstyle.api.AuditListener;
-import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Calendar;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.ResourceBundle;
/**
* Base abstract class for Checkstyle reports.
*
- * @version $Id: CheckstyleReport.java 1155028 2011-08-08 17:53:46Z olamy $
+ * @version $Id$
* @since 2.8
*/
public abstract class AbstractCheckstyleReport
@@ -59,12 +60,14 @@ public abstract class AbstractCheckstyle
{
public static final String PLUGIN_RESOURCES = "org/apache/maven/plugin/checkstyle";
+ protected static final String JAVA_FILES = "**\\/*.java";
+
/**
* Skip entire check.
*
- * @parameter expression="${checkstyle.skip}" default-value="false"
* @since 2.2
*/
+ @Parameter( property = "checkstyle.skip", defaultValue = "false" )
protected boolean skip;
/**
@@ -72,134 +75,107 @@ public abstract class AbstractCheckstyle
* evaluated if the goal is run directly from the command line. If the goal
* is run indirectly as part of a site generation, the output directory
* configured in Maven Site Plugin is used instead.
- *
- * @parameter default-value="${project.reporting.outputDirectory}"
- * @required
*/
+ @Parameter( defaultValue = "${project.reporting.outputDirectory}", required = true )
private File outputDirectory;
/**
* Specifies the path and filename to save the checkstyle output. The format
* of the output file is determined by the <code>outputFileFormat</code>
* parameter.
- *
- * @parameter expression="${checkstyle.output.file}"
- * default-value="${project.build.directory}/checkstyle-result.xml"
*/
+ @Parameter( property = "checkstyle.output.file", defaultValue = "${project.build.directory}/checkstyle-result.xml" )
private File outputFile;
/**
* If <code>null</code>, the Checkstyle plugin will display violations on stdout.
* Otherwise, a text file will be created with the violations.
- *
- * @parameter
*/
+ @Parameter
private File useFile;
/**
* Specifies the format of the output to be used when writing to the output
* file. Valid values are "plain" and "xml".
- *
- * @parameter expression="${checkstyle.output.format}" default-value="xml"
*/
+ @Parameter( property = "checkstyle.output.format", defaultValue = "xml" )
private String outputFileFormat;
/**
* Specifies if the Rules summary should be enabled or not.
- *
- * @parameter expression="${checkstyle.enable.rules.summary}"
- * default-value="true"
*/
+ @Parameter( property = "checkstyle.enable.rules.summary", defaultValue = "true" )
private boolean enableRulesSummary;
/**
* Specifies if the Severity summary should be enabled or not.
- *
- * @parameter expression="${checkstyle.enable.severity.summary}"
- * default-value="true"
*/
+ @Parameter( property = "checkstyle.enable.severity.summary", defaultValue = "true" )
private boolean enableSeveritySummary;
/**
* Specifies if the Files summary should be enabled or not.
- *
- * @parameter expression="${checkstyle.enable.files.summary}"
- * default-value="true"
*/
+ @Parameter( property = "checkstyle.enable.files.summary", defaultValue = "true" )
private boolean enableFilesSummary;
/**
* Specifies if the RSS should be enabled or not.
- *
- * @parameter expression="${checkstyle.enable.rss}" default-value="true"
*/
+ @Parameter( property = "checkstyle.enable.rss", defaultValue = "true" )
private boolean enableRSS;
/**
* SiteTool.
*
* @since 2.2
- * @component role="org.apache.maven.doxia.tools.SiteTool"
- * @required
- * @readonly
*/
+ @Component( role = SiteTool.class )
protected SiteTool siteTool;
/**
* The Maven Project Object.
- *
- * @parameter default-value="${project}"
- * @required
- * @readonly
*/
+ @Component
protected MavenProject project;
/**
* Link the violation line numbers to the source xref. Will link
* automatically if Maven JXR plugin is being used.
*
- * @parameter expression="${linkXRef}" default-value="true"
* @since 2.1
*/
+ @Parameter( property = "linkXRef", defaultValue = "true" )
private boolean linkXRef;
/**
* Location of the Xrefs to link to.
- *
- * @parameter default-value="${project.reporting.outputDirectory}/xref"
*/
+ @Parameter( defaultValue = "${project.reporting.outputDirectory}/xref" )
private File xrefLocation;
/**
- * @component
- * @required
- * @readonly
*/
+ @Component
private Renderer siteRenderer;
/**
- * @component
- * @required
- * @readonly
*/
+ @Component
protected ResourceManager locator;
/**
* CheckstyleRssGenerator.
*
* @since 2.4
- * @component role="org.apache.maven.plugin.checkstyle.rss.CheckstyleRssGenerator" role-hint="default"
- * @required
- * @readonly
*/
+ @Component( role = CheckstyleRssGenerator.class, hint = "default" )
protected CheckstyleRssGenerator checkstyleRssGenerator;
/**
* @since 2.5
- * @component role="org.apache.maven.plugin.checkstyle.CheckstyleExecutor" role-hint="default"
- * @required
- * @readonly
*/
+ @Component( role = CheckstyleExecutor.class, hint = "default" )
protected CheckstyleExecutor checkstyleExecutor;
protected ByteArrayOutputStream stringOutputStream;
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=1360089&r1=1360088&r2=1360089&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 Wed Jul 11 09:51:32 2012
@@ -19,23 +19,24 @@ package org.apache.maven.plugin.checksty
* under the License.
*/
-import java.io.File;
-import java.util.List;
-
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.MavenReportException;
+import java.io.File;
+import java.util.List;
+
/**
* Perform a Checkstyle analysis, and generate a report on violations,
* aggregating the result in the project which started this mojo.
*
- * @version $Id: CheckstyleReport.java 1155028 2011-08-08 17:53:46Z olamy $
- * @goal checkstyle-aggregate
- * @aggregator
- * @requiresDependencyResolution compile
- * @threadSafe
+ * @version $Id$
* @since 2.8
*/
+@Mojo( name = "checkstyle-aggregate", aggregator = true, requiresDependencyResolution = ResolutionScope.COMPILE,
+ threadSafe = true )
public class CheckstyleAggregateReport
extends AbstractCheckstyleReport
{
@@ -43,24 +44,23 @@ public class CheckstyleAggregateReport
/**
* Specifies the names filter of the source files to be used for Checkstyle.
*
- * @parameter expression="${checkstyle.includes}" default-value="**\/*.java"
- * @required
+ * <strong>Note:</strong> default value is {@code **\/*.java}.
*/
+ @Parameter( property = "checkstyle.includes", defaultValue = JAVA_FILES, required = true )
private String includes;
/**
* Specifies the names filter of the source files to be excluded for
* Checkstyle.
- *
- * @parameter expression="${checkstyle.excludes}"
*/
+ @Parameter( property = "checkstyle.excludes" )
private String excludes;
/**
* <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
@@ -68,42 +68,40 @@ public class CheckstyleAggregateReport
* 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 expression="${checkstyle.config.location}"
- * default-value="config/sun_checks.xml"
*/
+ @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
@@ -111,16 +109,15 @@ public class CheckstyleAggregateReport
* parameter).
* </p>
*
- * @parameter expression="${checkstyle.properties.location}"
* @since 2.0-beta-2
*/
+ @Parameter( property = "checkstyle.properties.location" )
private String propertiesLocation;
/**
* Allows for specifying raw property expansion information.
- *
- * @parameter
*/
+ @Parameter
private String propertyExpansion;
/**
@@ -139,91 +136,85 @@ public class CheckstyleAggregateReport
* <p>
* <code>
* <module name="RegexpHeader">
- * <property name="headerFile" value="${checkstyle.header.file}"/>
+ * <property name="headerFile" value="${checkstyle.header.file}"/>
* </module>
* </code>
* </p>
*
- * @parameter expression="${checkstyle.header.file}" default-value="LICENSE.txt"
* @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 default-value="${project.build.directory}/checkstyle-cachefile"
*/
+ @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>
*
- * @parameter expression="${checkstyle.suppressions.location}"
* @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.
*
- * @parameter expression="${checkstyle.suppression.expression}"
- * default-value="checkstyle.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 default-value="false"
*/
+ @Parameter( defaultValue = "false" )
private boolean failsOnError;
/**
* Specifies the location of the source directory to be used for Checkstyle.
- *
- * @parameter default-value="${project.build.sourceDirectory}"
- * @required
*/
+ @Parameter( defaultValue = "${project.build.sourceDirectory}", required = true )
private File sourceDirectory;
/**
* Specifies the location of the test source directory to be used for
* Checkstyle.
*
- * @parameter default-value="${project.build.testSourceDirectory}"
* @since 2.2
*/
+ @Parameter( defaultValue = "${project.build.testSourceDirectory}" )
private File testSourceDirectory;
/**
* Include or not the test source directory to be used for Checkstyle.
*
- * @parameter default-value="${false}"
* @since 2.2
*/
+ @Parameter( defaultValue = "false" )
private boolean includeTestSourceDirectory;
/**
* Output errors to console.
- *
- * @parameter default-value="false"
*/
+ @Parameter( defaultValue = "false" )
private boolean consoleOutput;
/**
@@ -231,18 +222,17 @@ public class CheckstyleAggregateReport
* 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.
*
- * @parameter expression="${encoding}" default-value="${project.build.sourceEncoding}"
* @since 2.2
*/
+ @Parameter( property = "encoding", defaultValue = "${project.build.sourceEncoding}" )
private String encoding;
/**
* The projects in the reactor for aggregation report.
*
- * @parameter expression="${reactorProjects}"
- * @readonly
* @since 2.8
*/
+ @Parameter( property = "reactorProjects", readonly = true )
private List<MavenProject> reactorProjects;
/** {@inheritDoc} */
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=1360089&r1=1360088&r2=1360089&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 Wed Jul 11 09:51:32 2012
@@ -19,6 +19,13 @@ package org.apache.maven.plugin.checksty
* under the License.
*/
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.reporting.MavenReportException;
+import org.codehaus.plexus.util.StringUtils;
+
import java.io.File;
import java.net.URL;
import java.util.Collections;
@@ -26,10 +33,6 @@ import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.reporting.MavenReportException;
-import org.codehaus.plexus.util.StringUtils;
-
/**
* Perform a Checkstyle analysis, and generate a report on violations.
*
@@ -37,10 +40,8 @@ import org.codehaus.plexus.util.StringUt
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
* @version $Id$
- * @goal checkstyle
- * @requiresDependencyResolution compile
- * @threadSafe
*/
+@Mojo( name = "checkstyle", requiresDependencyResolution = ResolutionScope.COMPILE, threadSafe = true )
public class CheckstyleReport
extends AbstractCheckstyleReport
{
@@ -64,24 +65,23 @@ public class CheckstyleReport
/**
* Specifies the names filter of the source files to be used for Checkstyle.
*
- * @parameter expression="${checkstyle.includes}" default-value="**\/*.java"
- * @required
+ * <strong>Note:</strong> default value is {@code **\/*.java}.
*/
+ @Parameter( property = "checkstyle.includes", defaultValue = JAVA_FILES, required = true )
private String includes;
/**
* Specifies the names filter of the source files to be excluded for
* Checkstyle.
- *
- * @parameter expression="${checkstyle.excludes}"
*/
+ @Parameter( property = "checkstyle.excludes" )
private String excludes;
/**
* <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
@@ -89,51 +89,49 @@ public class CheckstyleReport
* 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 expression="${checkstyle.config.location}"
- * default-value="config/sun_checks.xml"
*/
+ @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".
*
- * @parameter default-value="sun"
* @deprecated Use configLocation instead.
*/
+ @Parameter( defaultValue = "sun" )
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
@@ -141,34 +139,33 @@ public class CheckstyleReport
* parameter).
* </p>
*
- * @parameter expression="${checkstyle.properties.location}"
* @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.
*
- * @parameter
* @deprecated Use propertiesLocation instead.
*/
+ @Parameter
private File propertiesFile;
/**
* Specifies the URL of the Checkstyle properties that will be used to check
* the source.
*
- * @parameter
* @deprecated Use propertiesLocation instead.
*/
+ @Parameter
private URL propertiesURL;
/**
* Allows for specifying raw property expansion information.
- *
- * @parameter
*/
+ @Parameter
private String propertyExpansion;
/**
@@ -187,14 +184,14 @@ public class CheckstyleReport
* <p>
* <code>
* <module name="RegexpHeader">
- * <property name="headerFile" value="${checkstyle.header.file}"/>
+ * <property name="headerFile" value="${checkstyle.header.file}"/>
* </module>
* </code>
* </p>
*
- * @parameter expression="${checkstyle.header.file}" default-value="LICENSE.txt"
* @since 2.0-beta-2
*/
+ @Parameter( property = "checkstyle.header.file", defaultValue = "LICENSE.txt" )
private String headerLocation;
/**
@@ -202,47 +199,45 @@ public class CheckstyleReport
* is used by Checkstyle to verify that source code has the correct
* license header.
*
- * @parameter expression="${basedir}/LICENSE.txt"
* @deprecated Use headerLocation instead.
*/
+ @Parameter( defaultValue = "${basedir}/LICENSE.txt" )
private File headerFile;
/**
* Specifies the cache file used to speed up Checkstyle on successive runs.
- *
- * @parameter default-value="${project.build.directory}/checkstyle-cachefile"
*/
+ @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>
*
- * @parameter expression="${checkstyle.suppressions.location}"
* @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.
*
- * @parameter expression="${checkstyle.suppression.expression}"
- * default-value="checkstyle.suppressions.file"
* @since 2.1
*/
+ @Parameter( property = "checkstyle.suppression.expression", defaultValue = "checkstyle.suppressions.file" )
private String suppressionsFileExpression;
/**
@@ -252,9 +247,9 @@ public class CheckstyleReport
* property. This allows using the Checkstyle property in your own custom
* checkstyle configuration file when specifying a suppressions file.
*
- * @parameter
* @deprecated Use suppressionsLocation instead.
*/
+ @Parameter
private String suppressionsFile;
/**
@@ -263,7 +258,7 @@ public class CheckstyleReport
* the Checkstyle <a
* href="http://checkstyle.sourceforge.net/config.html#Packages">Packages</a>.
* </p>
- *
+ * <p/>
* <p>
* 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
@@ -271,57 +266,53 @@ public class CheckstyleReport
* file before being passed to Checkstyle for loading.
* </p>
*
- * @parameter
* @since 2.0-beta-2
*/
+ @Parameter
private String packageNamesLocation;
/**
* Specifies the location of the package names XML to be used to configure
* Checkstyle.
*
- * @parameter
* @deprecated Use packageNamesLocation instead.
*/
+ @Parameter
private String packageNamesFile;
/**
* Specifies if the build should fail upon a violation.
- *
- * @parameter default-value="false"
*/
+ @Parameter( defaultValue = "false" )
private boolean failsOnError;
/**
* Specifies the location of the source directory to be used for Checkstyle.
- *
- * @parameter default-value="${project.build.sourceDirectory}"
- * @required
*/
+ @Parameter( defaultValue = "${project.build.sourceDirectory}", required = true )
private File sourceDirectory;
/**
* Specifies the location of the test source directory to be used for
* Checkstyle.
*
- * @parameter default-value="${project.build.testSourceDirectory}"
* @since 2.2
*/
+ @Parameter( defaultValue = "${project.build.testSourceDirectory}" )
private File testSourceDirectory;
/**
* Include or not the test source directory to be used for Checkstyle.
*
- * @parameter default-value="${false}"
* @since 2.2
*/
+ @Parameter( defaultValue = "false" )
private boolean includeTestSourceDirectory;
/**
* Output errors to console.
- *
- * @parameter default-value="false"
*/
+ @Parameter( defaultValue = "false" )
private boolean consoleOutput;
/**
@@ -329,9 +320,9 @@ public class CheckstyleReport
* 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.
*
- * @parameter expression="${encoding}" default-value="${project.build.sourceEncoding}"
* @since 2.2
*/
+ @Parameter( property = "encoding", defaultValue = "${project.build.sourceEncoding}" )
private String encoding;
/** {@inheritDoc} */
Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java?rev=1360089&r1=1360088&r2=1360089&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java Wed Jul 11 09:51:32 2012
@@ -19,18 +19,18 @@ package org.apache.maven.plugin.checksty
* under the License.
*/
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Reader;
-
+import com.puppycrawl.tools.checkstyle.DefaultLogger;
+import com.puppycrawl.tools.checkstyle.XMLLogger;
+import com.puppycrawl.tools.checkstyle.api.AuditListener;
+import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;
@@ -38,10 +38,14 @@ import org.codehaus.plexus.util.xml.pull
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-import com.puppycrawl.tools.checkstyle.DefaultLogger;
-import com.puppycrawl.tools.checkstyle.XMLLogger;
-import com.puppycrawl.tools.checkstyle.api.AuditListener;
-import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Reader;
/**
* Perform a violation check against the last Checkstyle run to see if there are
@@ -50,87 +54,83 @@ import com.puppycrawl.tools.checkstyle.a
*
* @author <a href="mailto:joakim@erdfelt.net">Joakim Erdfelt</a>
* @version $Id$
- * @goal check
- * @phase verify
- * @requiresDependencyResolution test
- * @threadSafe
*/
+@Mojo( name = "check", defaultPhase = LifecyclePhase.VERIFY, requiresDependencyResolution = ResolutionScope.TEST,
+ threadSafe = true )
public class CheckstyleViolationCheckMojo
extends AbstractMojo
{
+
+ private static final String JAVA_FILES = "**\\/*.java";
+
/**
* Specifies the path and filename to save the Checkstyle output. The format
* of the output file is determined by the <code>outputFileFormat</code>
* parameter.
- *
- * @parameter expression="${checkstyle.output.file}"
- * default-value="${project.build.directory}/checkstyle-result.xml"
*/
+ @Parameter( property = "checkstyle.output.file", defaultValue = "${project.build.directory}/checkstyle-result.xml" )
private File outputFile;
/**
* Specifies the format of the output to be used when writing to the output
* file. Valid values are "plain" and "xml".
- *
- * @parameter expression="${checkstyle.output.format}" default-value="xml"
*/
+ @Parameter( property = "checkstyle.output.format", defaultValue = "xml" )
private String outputFileFormat;
/**
* Do we fail the build on a violation?
- *
- * @parameter expression="${checkstyle.failOnViolation}"
- * default-value="true"
*/
+ @Parameter( property = "checkstyle.failOnViolation", defaultValue = "true" )
private boolean failOnViolation;
/**
* The maximum number of allowed violations. The execution fails only if the
* number of violations is above this limit.
*
- * @parameter expression="${checkstyle.maxAllowedViolations}" default-value="0"
* @since 2.3
*/
+ @Parameter( property = "checkstyle.maxAllowedViolations", defaultValue = "0" )
private int maxAllowedViolations = 0;
/**
* The lowest severity level that is considered a violation.
* Valid values are "error", "warning" and "info".
*
- * @parameter expression="${checkstyle.violationSeverity}" default-value="error"
* @since 2.2
*/
+ @Parameter( property = "checkstyle.violationSeverity", defaultValue = "error" )
private String violationSeverity = "error";
/**
* Skip entire check.
*
- * @parameter expression="${checkstyle.skip}" default-value="false"
* @since 2.2
*/
+ @Parameter( property = "checkstyle.skip", defaultValue = "false" )
private boolean skip;
/**
* Skip checktyle execution will only scan the outputFile.
*
- * @parameter expression="${checkstyle.skipExec}" default-value="false"
* @since 2.5
*/
+ @Parameter( property = "checkstyle.skipExec", defaultValue = "false" )
private boolean skipExec;
/**
* Output the detected violations to the console.
*
- * @parameter expression="${checkstyle.console}" default-value="false"
* @since 2.3
*/
+ @Parameter( property = "checkstyle.console", defaultValue = "false" )
private boolean logViolationsToConsole;
/**
* <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
@@ -138,42 +138,42 @@ public class CheckstyleViolationCheckMoj
* 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>
+ *
* @since 2.5
- * @parameter expression="${checkstyle.config.location}"
- * default-value="config/sun_checks.xml"
*/
+ @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
@@ -181,16 +181,15 @@ public class CheckstyleViolationCheckMoj
* parameter).
* </p>
*
- * @parameter expression="${checkstyle.properties.location}"
* @since 2.5
*/
+ @Parameter( property = "checkstyle.properties.location" )
private String propertiesLocation;
/**
* Allows for specifying raw property expansion information.
- *
- * @parameter
*/
+ @Parameter
private String propertyExpansion;
/**
@@ -209,53 +208,50 @@ public class CheckstyleViolationCheckMoj
* <p>
* <code>
* <module name="RegexpHeader">
- * <property name="headerFile" value="${checkstyle.header.file}"/>
+ * <property name="headerFile" value="${checkstyle.header.file}"/>
* </module>
* </code>
* </p>
*
- * @parameter expression="${checkstyle.header.file}"
- * default-value="LICENSE.txt"
* @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 default-value="${project.build.directory}/checkstyle-cachefile"
*/
+ @Parameter( defaultValue = "${project.build.directory}/checkstyle-cachefile" )
private String cacheFile;
/**
* The key to be used in the properties for the suppressions file.
*
- * @parameter expression="${checkstyle.suppression.expression}"
- * default-value="checkstyle.suppressions.file"
* @since 2.1
*/
+ @Parameter( property = "checkstyle.suppression.expression", defaultValue = "checkstyle.suppressions.file" )
private 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>
*
- * @parameter expression="${checkstyle.suppressions.location}"
* @since 2.0-beta-2
*/
+ @Parameter( property = "checkstyle.suppressions.location" )
private String suppressionsLocation;
/**
@@ -263,89 +259,78 @@ public class CheckstyleViolationCheckMoj
* 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.
*
- * @parameter expression="${encoding}" default-value="${project.build.sourceEncoding}"
* @since 2.2
*/
+ @Parameter( property = "encoding", defaultValue = "${project.build.sourceEncoding}" )
private String encoding;
/**
* @since 2.5
- * @component role="org.apache.maven.plugin.checkstyle.CheckstyleExecutor" role-hint="default"
- * @required
- * @readonly
*/
+ @Component( role = CheckstyleExecutor.class, hint = "default" )
protected CheckstyleExecutor checkstyleExecutor;
/**
* Output errors to console.
- *
- * @parameter default-value="false"
*/
+ @Parameter( defaultValue = "false" )
private boolean consoleOutput;
/**
* The Maven Project Object.
- *
- * @parameter default-value="${project}"
- * @required
- * @readonly
*/
+ @Component
protected MavenProject project;
/**
* If <code>null</code>, the Checkstyle plugin will display violations on stdout.
* Otherwise, a text file will be created with the violations.
- *
- * @parameter
*/
+ @Parameter
private File useFile;
/**
* Specifies the names filter of the source files to be excluded for
* Checkstyle.
- *
- * @parameter expression="${checkstyle.excludes}"
*/
+ @Parameter( property = "checkstyle.excludes" )
private String excludes;
/**
* Specifies the names filter of the source files to be used for Checkstyle.
*
- * @parameter expression="${checkstyle.includes}" default-value="**\/*.java"
- * @required
+ * <strong>Note:</strong> default value is {@code **\/*.java}.
*/
+ @Parameter( property = "checkstyle.includes", defaultValue = JAVA_FILES, required = true )
private String includes;
/**
* Specifies if the build should fail upon a violation.
- *
- * @parameter default-value="false"
*/
+ @Parameter( defaultValue = "false" )
private boolean failsOnError;
/**
* Specifies the location of the test source directory to be used for
* Checkstyle.
*
- * @parameter default-value="${project.build.testSourceDirectory}"
* @since 2.2
*/
+ @Parameter( defaultValue = "${project.build.testSourceDirectory}" )
private File testSourceDirectory;
/**
* Include or not the test source directory to be used for Checkstyle.
*
- * @parameter default-value="${false}"
* @since 2.2
*/
+ @Parameter( defaultValue = "false" )
private boolean includeTestSourceDirectory;
/**
* Specifies the location of the source directory to be used for Checkstyle.
- *
- * @parameter default-value="${project.build.sourceDirectory}"
- * @required
*/
+ @Parameter( defaultValue = "${project.build.sourceDirectory}", required = true )
private File sourceDirectory;
private ByteArrayOutputStream stringOutputStream;