You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2012/07/01 15:13:35 UTC
svn commit: r1355881 - in /maven/plugins/trunk/maven-jar-plugin: ./
src/main/java/org/apache/maven/plugin/jar/
Author: olamy
Date: Sun Jul 1 13:13:34 2012
New Revision: 1355881
URL: http://svn.apache.org/viewvc?rev=1355881&view=rev
Log:
[MJAR-158] use maven-plugin-tools' java 5 annotations
Submitted by Tony Chemit.
Modified:
maven/plugins/trunk/maven-jar-plugin/pom.xml
maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/AbstractJarMojo.java
maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarMojo.java
maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarSignMojo.java
maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarSignVerifyMojo.java
maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/TestJarMojo.java
Modified: maven/plugins/trunk/maven-jar-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/pom.xml?rev=1355881&r1=1355880&r2=1355881&view=diff
==============================================================================
--- maven/plugins/trunk/maven-jar-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-jar-plugin/pom.xml Sun Jul 1 13:13:34 2012
@@ -66,6 +66,7 @@ under the License.
<properties>
<mavenArchiverVersion>2.5</mavenArchiverVersion>
<mavenVersion>2.0.6</mavenVersion>
+ <mavenPluginPluginVersion>3.1-SNAPSHOT</mavenPluginPluginVersion>
</properties>
<dependencies>
@@ -95,6 +96,12 @@ under the License.
<artifactId>maven-archiver</artifactId>
<version>${mavenArchiverVersion}</version>
</dependency>
+ <!-- dependencies to annotations -->
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>${mavenPluginPluginVersion}</version>
+ </dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
@@ -134,6 +141,39 @@ under the License.
</dependency>
</dependencies>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>${mavenPluginPluginVersion}</version>
+ <configuration>
+ <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+ </configuration>
+ <executions>
+ <execution>
+ <id>mojo-descriptor</id>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>${mavenPluginPluginVersion}</version>
+ </plugin>
+ </plugins>
+ </reporting>
+
<profiles>
<profile>
<id>run-its</id>
Modified: maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/AbstractJarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/AbstractJarMojo.java?rev=1355881&r1=1355880&r2=1355881&view=diff
==============================================================================
--- maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/AbstractJarMojo.java (original)
+++ maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/AbstractJarMojo.java Sun Jul 1 13:13:34 2012
@@ -24,8 +24,11 @@ import org.apache.maven.archiver.MavenAr
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
+import org.codehaus.plexus.archiver.Archiver;
import org.codehaus.plexus.archiver.jar.JarArchiver;
import java.io.File;
Modified: maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarMojo.java?rev=1355881&r1=1355880&r2=1355881&view=diff
==============================================================================
--- maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarMojo.java (original)
+++ maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarMojo.java Sun Jul 1 13:13:34 2012
@@ -19,6 +19,11 @@ package org.apache.maven.plugin.jar;
* under the License.
*/
+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 java.io.File;
/**
@@ -26,30 +31,24 @@ import java.io.File;
*
* @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id$
- * @goal jar
- * @phase package
- * @requiresProject
- * @threadSafe
- * @requiresDependencyResolution runtime
*/
+@Mojo( name = "jar", defaultPhase = LifecyclePhase.PACKAGE, requiresProject = true, threadSafe = true,
+ requiresDependencyResolution = ResolutionScope.RUNTIME )
public class JarMojo
extends AbstractJarMojo
{
/**
* Directory containing the classes and resource files that should be packaged into the JAR.
- *
- * @parameter default-value="${project.build.outputDirectory}"
- * @required
*/
+ @Parameter( defaultValue = "${project.build.outputDirectory}", required = true )
private File classesDirectory;
/**
* Classifier to add to the artifact generated. If given, the artifact will be attached.
* If this is not given,it will merely be written to the output directory
* according to the finalName.
- *
- * @parameter
*/
+ @Parameter
private String classifier;
protected String getClassifier()
Modified: maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarSignMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarSignMojo.java?rev=1355881&r1=1355880&r2=1355881&view=diff
==============================================================================
--- maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarSignMojo.java (original)
+++ maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarSignMojo.java Sun Jul 1 13:13:34 2012
@@ -23,6 +23,11 @@ import org.apache.commons.lang.SystemUti
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
+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.apache.maven.project.MavenProjectHelper;
import org.apache.maven.artifact.handler.ArtifactHandler;
@@ -44,117 +49,99 @@ import java.util.StringTokenizer;
*
* @author <a href="jerome@coffeebreaks.org">Jerome Lacoste</a>
* @version $Id$
- * @goal sign
- * @phase package
- * @requiresProject
* @todo refactor the common code with javadoc plugin
- * @requiresDependencyResolution runtime
* @deprecated As of version 2.3, this goal is no longer supported in favor of the dedicated maven-jarsigner-plugin.
*/
+@Mojo( name = "sign", defaultPhase = LifecyclePhase.PACKAGE, requiresProject = true,
+ requiresDependencyResolution = ResolutionScope.RUNTIME )
public class JarSignMojo
extends AbstractMojo
{
/**
* Set this to <code>true</code> to disable signing.
* Useful to speed up build process in development environment.
- *
- * @parameter expression="${maven.jar.sign.skip}" default-value="false"
*/
+ @Parameter( property = "maven.jar.sign.skip", defaultValue = "false" )
private boolean skip;
/**
* The working directory in which the jarsigner executable will be run.
- *
- * @parameter expression="${workingdir}" default-value="${basedir}"
- * @required
*/
+ @Parameter( property = "workingdir", defaultValue = "${basedir}", required = true )
private File workingDirectory;
/**
* Directory containing the generated JAR.
- *
- * @parameter expression="${project.build.directory}"
- * @required
- * @readonly
*/
+ @Parameter( property = "project.build.directory", required = true, readonly = true )
private File basedir;
/**
* Name of the generated JAR (without classifier and extension).
- *
- * @parameter alias="jarname" expression="${project.build.finalName}"
- * @required
*/
+ @Parameter( alias = "jarname", property = "project.build.finalName", required = true )
private String finalName;
/**
* Path of the jar to sign. When specified, the finalName is ignored.
- *
- * @parameter alias="jarpath" default-value="${project.build.directory}/${project.build.finalName}.${project.packaging}"
*/
+ @Parameter( alias = "jarpath",
+ defaultValue = "${project.build.directory}/${project.build.finalName}.${project.packaging}" )
private File jarPath;
/**
* See <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/jarsigner.html#Options">options</a>.
- *
- * @parameter expression="${keystore}"
*/
+ @Parameter( property = "keystore" )
private String keystore;
/**
* See <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/jarsigner.html#Options">options</a>.
- *
- * @parameter expression="${storepass}"
*/
+ @Parameter( property = "storepass" )
private String storepass;
/**
* See <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/jarsigner.html#Options">options</a>.
- *
- * @parameter expression="${keypass}"
*/
+ @Parameter( property = "keypass" )
private String keypass;
/**
* See <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/jarsigner.html#Options">options</a>.
*
- * @parameter expression="${sigfile}"
* @todo make a File?
*/
+ @Parameter( property = "sigfile" )
private String sigfile;
/**
* See <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/jarsigner.html#Options">options</a>.
* <p/>
* Not specifying this argument will sign the jar in-place (your original jar is going to be overwritten).
- *
- * @parameter expression="${signedjar}"
*/
+ @Parameter( property = "signedjar" )
private File signedjar;
/**
* See <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/jarsigner.html#Options">options</a>.
* The corresponding option in the command line is -storetype.
- *
- * @parameter expression="${type}"
*/
+ @Parameter( property = "type" )
private String type;
/**
* See <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/jarsigner.html#Options">options</a>.
- *
- * @parameter expression="${alias}"
- * @required
*/
+ @Parameter( property = "alias", required = true )
private String alias;
/**
* Automatically verify a jar after signing it.
* <p/>
* See <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/jarsigner.html#Options">options</a>.
- *
- * @parameter expression="${verify}" default-value="false"
*/
+ @Parameter( property = "verify", defaultValue = "false" )
private boolean verify;
/**
@@ -167,31 +154,26 @@ public class JarSignMojo
/**
* Enable verbose.
* See <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/jarsigner.html#Options">options</a>.
- *
- * @parameter expression="${verbose}" default-value="false"
*/
+ @Parameter( property = "verbose", defaultValue = "false" )
private boolean verbose;
/**
- * @component
*/
+ @Component
private MavenProjectHelper projectHelper;
/**
* The Maven project.
- *
- * @parameter expression="${project}"
- * @required
- * @readonly
*/
+ @Component
private MavenProject project;
/**
* Classifier to use for the generated artifact.
* If not specified, the generated artifact becomes the primary artifact.
- *
- * @parameter expression="${classifier}"
*/
+ @Parameter( property = "classifier" )
private String classifier;
public void execute()
Modified: maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarSignVerifyMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarSignVerifyMojo.java?rev=1355881&r1=1355880&r2=1355881&view=diff
==============================================================================
--- maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarSignVerifyMojo.java (original)
+++ maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarSignVerifyMojo.java Sun Jul 1 13:13:34 2012
@@ -30,6 +30,10 @@ import org.apache.commons.lang.SystemUti
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
+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.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils;
@@ -41,71 +45,59 @@ import org.codehaus.plexus.util.cli.Stre
*
* @author <a href="jerome@coffeebreaks.org">Jerome Lacoste</a>
* @version $Id$
- * @goal sign-verify
- * @phase package
- * @requiresProject
* @todo refactor the common code with javadoc plugin
- * @requiresDependencyResolution runtime
* @deprecated As of version 2.3, this goal is no longer supported in favor of the dedicated maven-jarsigner-plugin.
*/
+@Mojo( name = "sign-verify", defaultPhase = LifecyclePhase.PACKAGE, requiresProject = true,
+ requiresDependencyResolution = ResolutionScope.RUNTIME )
public class JarSignVerifyMojo
extends AbstractMojo
{
/**
* The working directory in which the jarsigner executable will be run.
- *
- * @parameter expression="${workingdir}" default-value="${basedir}"
- * @required
*/
+ @Parameter( property = "workingdir", defaultValue = "${basedir}", required = true )
private File workingDirectory;
/**
* Directory containing the generated JAR.
- *
- * @parameter expression="${project.build.directory}"
- * @required
- * @readonly
*/
+ @Parameter( property = "project.build.directory", required = true, readonly = true )
private File basedir;
/**
* Name of the generated JAR (without classifier and extension).
- *
- * @parameter alias="jarname" expression="${project.build.finalName}"
- * @required
*/
+ @Parameter( alias = "jarname", property = "project.build.finalName", required = true )
private String finalName;
/**
* Path of the signed jar. When specified, the finalName is ignored.
- *
- * @parameter expression="${jarpath}"
*/
+ @Parameter( property = "jarpath" )
private File jarPath;
/**
* Check certificates. Requires {@link #setVerbose(boolean)}.
* See <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/jarsigner.html#Options">options</a>.
- *
- * @parameter expression="${checkcerts}" default-value="false"
*/
+ @Parameter( property = "checkcerts", defaultValue = "false" )
private boolean checkCerts;
/**
* Enable verbose
* See <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/jarsigner.html#Options">options</a>.
- *
- * @parameter expression="${verbose}" default-value="false"
*/
+ @Parameter( property = "verbose", defaultValue = "false" )
private boolean verbose;
- /** When <code>true</code> this will make the execute() operation fail,
+ /**
+ * When <code>true</code> this will make the execute() operation fail,
* throwing an exception, when verifying a non signed jar.
* Primarily to keep backwards compatibility with existing code, and allow reusing the
* bean in unattended operations when set to <code>false</code>.
- *
- * @parameter expression="${errorWhenNotSigned}" default-value="true"
- **/
+ */
+ @Parameter( property = "errorWhenNotSigned", defaultValue = "true" )
private boolean errorWhenNotSigned = true;
/**
Modified: maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/TestJarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/TestJarMojo.java?rev=1355881&r1=1355880&r2=1355881&view=diff
==============================================================================
--- maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/TestJarMojo.java (original)
+++ maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/TestJarMojo.java Sun Jul 1 13:13:34 2012
@@ -21,18 +21,19 @@ package org.apache.maven.plugin.jar;
import java.io.File;
import org.apache.maven.plugin.MojoExecutionException;
+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;
/**
* Build a JAR of the test classes for the current project.
*
* @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id$
- * @goal test-jar
- * @phase package
- * @requiresProject
- * @threadSafe
- * @requiresDependencyResolution test
*/
+@Mojo( name = "test-jar", defaultPhase = LifecyclePhase.PACKAGE, requiresProject = true, threadSafe = true,
+ requiresDependencyResolution = ResolutionScope.TEST )
public class TestJarMojo
extends AbstractJarMojo
{
@@ -40,17 +41,14 @@ public class TestJarMojo
/**
* Set this to <code>true</code> to bypass unit tests entirely.
* Its use is <b>NOT RECOMMENDED</b>, but quite convenient on occasion.
- *
- * @parameter expression="${maven.test.skip}"
*/
+ @Parameter( property = "maven.test.skip" )
private boolean skip;
/**
* Directory containing the test classes and resource files that should be packaged into the JAR.
- *
- * @parameter default-value="${project.build.testOutputDirectory}"
- * @required
*/
+ @Parameter( defaultValue = "${project.build.testOutputDirectory}", required = true )
private File testClassesDirectory;
protected String getClassifier()