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/10 21:59:20 UTC
svn commit: r1359867 - in /maven/plugins/trunk/maven-pmd-plugin: ./
src/main/java/org/apache/maven/plugin/pmd/
Author: tchemit
Date: Tue Jul 10 19:59:19 2012
New Revision: 1359867
URL: http://svn.apache.org/viewvc?rev=1359867&view=rev
Log:
[MPMD-156] use maven-plugin-tools' java 5 annotations
Modified:
maven/plugins/trunk/maven-pmd-plugin/pom.xml
maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdReport.java
maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdViolationCheckMojo.java
maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReport.java
maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdViolationCheckMojo.java
maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java
maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdViolationCheckMojo.java
Modified: maven/plugins/trunk/maven-pmd-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/pom.xml?rev=1359867&r1=1359866&r2=1359867&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-pmd-plugin/pom.xml Tue Jul 10 19:59:19 2012
@@ -72,6 +72,18 @@ under the License.
</properties>
<build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
<plugins>
<plugin>
<groupId>org.codehaus.modello</groupId>
@@ -95,6 +107,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>
@@ -115,6 +138,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>
@@ -162,6 +190,13 @@ under the License.
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd</artifactId>
<version>${pmdVersion}</version>
+ <!-- Workaround to fix http://jira.codehaus.org/browse/MPLUGIN-221 -->
+ <exclusions>
+ <exclusion>
+ <groupId>com.ibm.icu</groupId>
+ <artifactId>icu4j</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<!-- test -->
Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdReport.java?rev=1359867&r1=1359866&r2=1359867&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdReport.java (original)
+++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdReport.java Tue Jul 10 19:59:19 2012
@@ -22,6 +22,8 @@ package org.apache.maven.plugin.pmd;
import net.sourceforge.pmd.PMD;
import org.apache.maven.doxia.siterenderer.Renderer;
import org.apache.maven.model.ReportPlugin;
+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.codehaus.plexus.util.FileUtils;
@@ -52,36 +54,28 @@ public abstract class AbstractPmdReport
{
/**
* The output directory for the intermediate XML report.
- *
- * @parameter expression="${project.build.directory}"
- * @required
*/
+ @Parameter( property = "project.build.directory", required = true )
protected File targetDirectory;
/**
* The output directory for the final HTML report. Note that this parameter is only evaluated if the goal is run
* directly from the command line or during the default lifecycle. If the goal is run indirectly as part of a site
* generation, the output directory configured in the Maven Site Plugin is used instead.
- *
- * @parameter expression="${project.reporting.outputDirectory}"
- * @required
*/
+ @Parameter( property = "project.reporting.outputDirectory", required = true )
protected File outputDirectory;
/**
* Site rendering component for generating the HTML report.
- *
- * @component
*/
+ @Component
private Renderer siteRenderer;
/**
* The project to analyse.
- *
- * @parameter expression="${project}"
- * @required
- * @readonly
*/
+ @Component
protected MavenProject project;
/**
@@ -89,31 +83,27 @@ public abstract class AbstractPmdReport
* "csv", "xml", "txt" or the full class name of the PMD renderer to use.
* See the net.sourceforge.pmd.renderers package javadoc for available renderers.
* XML is required if the pmd:check goal is being used.
- *
- * @parameter expression="${format}" default-value="xml"
*/
+ @Parameter( property = "format", defaultValue = "xml" )
protected String format = "xml";
/**
* Link the violation line numbers to the source xref. Links will be created
* automatically if the jxr plugin is being used.
- *
- * @parameter expression="${linkXRef}" default-value="true"
*/
+ @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;
/**
* Location of the Test Xrefs to link to.
- *
- * @parameter default-value="${project.reporting.outputDirectory}/xref-test"
*/
+ @Parameter( defaultValue = "${project.reporting.outputDirectory}/xref-test" )
private File xrefTestLocation;
/**
@@ -122,84 +112,76 @@ public abstract class AbstractPmdReport
* words, files are excluded based on their package and/or class name. If you want to exclude entire source root
* directories, use the parameter <code>excludeRoots</code> instead.
*
- * @parameter
* @since 2.2
*/
+ @Parameter
private List<String> excludes;
/**
* A list of files to include from checking. Can contain Ant-style wildcards and double wildcards.
* Defaults to **\/*.java.
*
- * @parameter
* @since 2.2
*/
+ @Parameter
private List<String> includes;
/**
* The directories containing the sources to be compiled.
- *
- * @parameter expression="${project.compileSourceRoots}"
- * @required
- * @readonly
*/
+ @Parameter( property = "project.compileSourceRoots", required = true, readonly = true )
private List<String> compileSourceRoots;
/**
* The directories containing the test-sources to be compiled.
- *
- * @parameter expression="${project.testCompileSourceRoots}"
- * @required
- * @readonly
*/
+ @Parameter( property = "project.testCompileSourceRoots", required = true, readonly = true )
private List<String> testSourceRoots;
/**
* The project source directories that should be excluded.
*
- * @parameter
* @since 2.2
*/
+ @Parameter
private File[] excludeRoots;
/**
* Run PMD on the tests.
*
- * @parameter default-value="false"
* @since 2.2
*/
+ @Parameter( defaultValue = "false" )
protected boolean includeTests;
/**
* Whether to build an aggregated report at the root, or build individual reports.
*
- * @parameter expression="${aggregate}" default-value="false"
* @since 2.2
*/
+ @Parameter( property = "aggregate", defaultValue = "false" )
protected boolean aggregate;
/**
* The file encoding to use when reading the Java sources.
*
- * @parameter expression="${encoding}" default-value="${project.build.sourceEncoding}"
* @since 2.3
*/
+ @Parameter( property = "encoding", defaultValue = "${project.build.sourceEncoding}" )
private String sourceEncoding;
/**
* The file encoding when writing non-HTML reports.
*
- * @parameter expression="${outputEncoding}" default-value="${project.reporting.outputEncoding}"
* @since 2.5
*/
+ @Parameter( property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}" )
private String outputEncoding;
/**
* The projects in the reactor for aggregation report.
- *
- * @parameter expression="${reactorProjects}"
- * @readonly
*/
+ @Parameter( property = "reactorProjects", readonly = true )
protected List<MavenProject> reactorProjects;
/**
Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdViolationCheckMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdViolationCheckMojo.java?rev=1359867&r1=1359866&r2=1359867&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdViolationCheckMojo.java (original)
+++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/AbstractPmdViolationCheckMojo.java Tue Jul 10 19:59:19 2012
@@ -22,6 +22,8 @@ package org.apache.maven.plugin.pmd;
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.Parameter;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
@@ -43,51 +45,40 @@ public abstract class AbstractPmdViolati
{
/**
* The location of the XML report to check, as generated by the PMD report.
- *
- * @parameter expression="${project.build.directory}"
- * @required
*/
+ @Parameter( property = "project.build.directory", required = true )
private File targetDirectory;
/**
* Whether to fail the build if the validation check fails.
- *
- * @parameter expression="${pmd.failOnViolation}" default-value="true"
- * @required
*/
+ @Parameter( property = "pmd.failOnViolation", defaultValue = "true", required = true )
protected boolean failOnViolation;
/**
* The project language, for determining whether to run the report.
- *
- * @parameter expression="${project.artifact.artifactHandler.language}"
- * @required
- * @readonly
*/
+ @Parameter( property = "project.artifact.artifactHandler.language", required = true, readonly = true )
private String language;
/**
* Whether to build an aggregated report at the root, or build individual reports.
*
- * @parameter expression="${aggregate}" default-value="false"
* @since 2.2
*/
+ @Parameter( property = "aggregate", defaultValue = "false" )
protected boolean aggregate;
/**
* Print details of check failures to build output.
- *
- * @parameter expression="${pmd.verbose}" default-value="false"
*/
+ @Parameter( property = "pmd.verbose", defaultValue = "false" )
private boolean verbose;
/**
* The project to analyze.
- *
- * @parameter expression="${project}"
- * @required
- * @readonly
*/
+ @Component
protected MavenProject project;
protected void executeCheck( String filename, String tagName, String key, int failurePriority )
Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReport.java?rev=1359867&r1=1359866&r2=1359867&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReport.java (original)
+++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReport.java Tue Jul 10 19:59:19 2012
@@ -26,6 +26,8 @@ import net.sourceforge.pmd.cpd.JavaLangu
import net.sourceforge.pmd.cpd.JavaTokenizer;
import net.sourceforge.pmd.cpd.Renderer;
import net.sourceforge.pmd.cpd.XMLRenderer;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.reporting.MavenReportException;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
@@ -51,27 +53,25 @@ import java.util.ResourceBundle;
*
* @author Mike Perham
* @version $Id$
- * @goal cpd
- * @threadSafe
* @since 2.0
*/
+@Mojo( name = "cpd", threadSafe = true )
public class CpdReport
extends AbstractPmdReport
{
/**
* The minimum number of tokens that need to be duplicated before it causes a violation.
- *
- * @parameter expression="${minimumTokens}" default-value="100"
*/
+ @Parameter( property = "minimumTokens", defaultValue = "100" )
private int minimumTokens;
/**
* Skip the CPD report generation. Most useful on the command line
* via "-Dcpd.skip=true".
*
- * @parameter expression="${cpd.skip}" default-value="false"
* @since 2.1
*/
+ @Parameter( property = "cpd.skip", defaultValue = "false" )
private boolean skip;
/**
@@ -79,17 +79,17 @@ public class CpdReport
* This means that <code>foo=42;</code> and <code>foo=43;</code> will be seen as equivalent.
* You may want to run PMD with this option off to start with and then switch it on to see what it turns up.
*
- * @parameter expression="${cpd.ignoreLiterals}" default-value="false"
* @since 2.5
*/
+ @Parameter( property = "cpd.ignoreLiterals", defaultValue = "false" )
private boolean ignoreLiterals;
/**
* Similar to <code>ignoreLiterals</code> but for identifiers; i.e., variable names, methods names, and so forth.
*
- * @parameter expression="${cpd.ignoreIdentifiers}" default-value="false"
* @since 2.5
*/
+ @Parameter( property = "cpd.ignoreIdentifiers", defaultValue = "false" )
private boolean ignoreIdentifiers;
/**
Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdViolationCheckMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdViolationCheckMojo.java?rev=1359867&r1=1359866&r2=1359867&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdViolationCheckMojo.java (original)
+++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdViolationCheckMojo.java Tue Jul 10 19:59:19 2012
@@ -25,6 +25,10 @@ import org.apache.maven.plugin.pmd.model
import org.apache.maven.plugin.pmd.model.CpdFile;
import org.apache.maven.plugin.pmd.model.Duplication;
import org.apache.maven.plugin.pmd.model.io.xpp3.CpdXpp3Reader;
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File;
@@ -36,12 +40,10 @@ import java.util.List;
* Fail the build if there were any CPD violations in the source code.
*
* @version $Id$
- * @goal cpd-check
- * @phase verify
- * @execute goal="cpd"
- * @threadSafe
* @since 2.0
*/
+@Mojo( name = "cpd-check", defaultPhase = LifecyclePhase.VERIFY, threadSafe = true )
+@Execute( goal = "cpd" )
public class CpdViolationCheckMojo
extends AbstractPmdViolationCheckMojo<Duplication>
{
@@ -49,18 +51,16 @@ public class CpdViolationCheckMojo
/**
* Skip the CPD violation checks. Most useful on the command line
* via "-Dcpd.skip=true".
- *
- * @parameter expression="${cpd.skip}" default-value="false"
*/
+ @Parameter( property = "cpd.skip", defaultValue = "false" )
private boolean skip;
/**
* Whether to fail the build if the validation check fails.
*
- * @parameter expression="${cpd.failOnViolation}" default-value="true"
- * @required
* @since 2.8
*/
+ @Parameter( property = "cpd.failOnViolation", defaultValue = "true", required = true )
protected boolean failOnViolation;
Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java?rev=1359867&r1=1359866&r2=1359867&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java (original)
+++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java Tue Jul 10 19:59:19 2012
@@ -36,6 +36,9 @@ import net.sourceforge.pmd.renderers.XML
import net.sourceforge.pmd.util.datasource.DataSource;
import net.sourceforge.pmd.util.datasource.FileDataSource;
import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.reporting.MavenReportException;
import org.codehaus.plexus.resource.ResourceManager;
import org.codehaus.plexus.resource.loader.FileResourceCreationException;
@@ -64,23 +67,20 @@ import java.util.ResourceBundle;
*
* @author Brett Porter
* @version $Id$
- * @goal pmd
- * @threadSafe
* @since 2.0
*/
+@Mojo( name = "pmd", threadSafe = true )
public class PmdReport
extends AbstractPmdReport
{
/**
* The target JDK to analyze based on. Should match the target used in the compiler plugin. Valid values are
* currently <code>1.3</code>, <code>1.4</code>, <code>1.5</code>, <code>1.6</code> and <code>1.7</code>.
- * <p>
+ * <p/>
* <b>Note:</b> support for <code>1.6</code> was added in version 2.3 of this plugin,
* support for <code>1.7</code> was added in version 2.7 of this plugin.
- * </p>
- *
- * @parameter expression="${targetJdk}"
*/
+ @Parameter( property = "targetJdk" )
private String targetJdk;
/**
@@ -90,43 +90,40 @@ public class PmdReport
* <b>Note:</b> if the parameter targetJdk is given, then this language parameter will be ignored.
* </p>
*
- * @parameter default-value="java"
* @since 2.8
*/
+ @Parameter( defaultValue = "java" )
private String language;
/**
* The rule priority threshold; rules with lower priority
* than this will not be evaluated.
*
- * @parameter expression="${minimumPriority}" default-value="5"
* @since 2.1
*/
+ @Parameter( property = "minimumPriority", defaultValue = "5" )
private int minimumPriority = 5;
/**
* Skip the PMD report generation. Most useful on the command line
* via "-Dpmd.skip=true".
*
- * @parameter expression="${pmd.skip}" default-value="false"
* @since 2.1
*/
+ @Parameter( property = "pmd.skip", defaultValue = "false" )
private boolean skip;
/**
* The PMD rulesets to use. See the <a href="http://pmd.sourceforge.net/rules/index.html">Stock Rulesets</a> for a
* list of some included. Since version 2.5, the ruleset "rulesets/maven.xml" is also available. Defaults to the
* java-basic, java-imports and java-unusedcode rulesets.
- *
- * @parameter
*/
+ @Parameter
private String[] rulesets = new String[]{ "java-basic", "java-unusedcode", "java-imports" };
/**
- * @component
- * @required
- * @readonly
*/
+ @Component
private ResourceManager locator;
/**
Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdViolationCheckMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdViolationCheckMojo.java?rev=1359867&r1=1359866&r2=1359867&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdViolationCheckMojo.java (original)
+++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdViolationCheckMojo.java Tue Jul 10 19:59:19 2012
@@ -25,6 +25,10 @@ import org.apache.maven.plugin.pmd.model
import org.apache.maven.plugin.pmd.model.PmdFile;
import org.apache.maven.plugin.pmd.model.Violation;
import org.apache.maven.plugin.pmd.model.io.xpp3.PmdXpp3Reader;
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
@@ -38,12 +42,10 @@ import java.util.List;
* Fail the build if there were any PMD violations in the source code.
*
* @version $Id$
- * @goal check
- * @phase verify
- * @execute goal="pmd"
- * @threadSafe
* @since 2.0
*/
+@Mojo( name = "check", defaultPhase = LifecyclePhase.VERIFY, threadSafe = true )
+@Execute( goal = "pmd" )
public class PmdViolationCheckMojo
extends AbstractPmdViolationCheckMojo<Violation>
{
@@ -52,18 +54,15 @@ public class PmdViolationCheckMojo
* will stop the build. Anything below will be warnings and will be
* displayed in the build output if verbose=true. Note: Minimum Priority = 5
* Maximum Priority = 0
- *
- * @parameter expression="${pmd.failurePriority}" default-value="5"
- * @required
*/
+ @Parameter( property = "pmd.failurePriority", defaultValue = "5", required = true )
private int failurePriority;
/**
* Skip the PMD checks. Most useful on the command line
* via "-Dpmd.skip=true".
- *
- * @parameter expression="${pmd.skip}" default-value="false"
*/
+ @Parameter( property = "pmd.skip", defaultValue = "false" )
private boolean skip;
/**