You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2012/06/29 23:40:39 UTC

svn commit: r1355570 - in /maven/plugins/trunk/maven-war-plugin: ./ src/main/java/org/apache/maven/plugin/war/

Author: rfscholte
Date: Fri Jun 29 21:40:37 2012
New Revision: 1355570

URL: http://svn.apache.org/viewvc?rev=1355570&view=rev
Log:
Fix MWAR-282: use maven-plugin-tools' java 5 annotations 
Contributed by Tony Chemit, reviewed and slightly changed by Robert Scholte

Modified:
    maven/plugins/trunk/maven-war-plugin/pom.xml
    maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
    maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarExplodedMojo.java
    maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarInPlaceMojo.java
    maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarManifestMojo.java
    maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java

Modified: maven/plugins/trunk/maven-war-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/pom.xml?rev=1355570&r1=1355569&r2=1355570&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-war-plugin/pom.xml Fri Jun 29 21:40:37 2012
@@ -36,6 +36,12 @@ under the License.
   <name>Maven WAR Plugin</name>
   <description>Builds a Web Application Archive (WAR) file from the project output and its dependencies.</description>
 
+  <contributors>
+    <contributor>
+      <name>Tony Chemit</name>
+    </contributor>
+  </contributors>
+  
   <prerequisites>
     <maven>${mavenVersion}</maven>
   </prerequisites>
@@ -98,6 +104,12 @@ under the License.
       <version>${mavenArchiverVersion}</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.maven.plugin-tools</groupId>
+      <artifactId>maven-plugin-annotations</artifactId>
+      <version>3.1-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-io</artifactId>
       <version>2.0.2</version>
@@ -138,7 +150,7 @@ under the License.
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
-      <version>3.0</version>
+      <version>3.0.1</version>
     </dependency>
 
     <dependency>
@@ -161,6 +173,34 @@ under the License.
     </dependency>
   </dependencies>
 
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-plugin-plugin</artifactId>
+        <version>3.1-SNAPSHOT</version>
+        <executions>
+          <execution>
+            <id>generate-descriptor</id>
+            <goals>
+              <goal>descriptor</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-plugin-plugin</artifactId>
+        <version>3.1-SNAPSHOT</version>
+      </plugin>
+    </plugins>
+  </reporting>
+
   <profiles>
     <profile>
       <id>run-its</id>

Modified: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java?rev=1355570&r1=1355569&r2=1355570&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java Fri Jun 29 21:40:37 2012
@@ -45,11 +45,14 @@ import org.apache.maven.plugin.war.packa
 import org.apache.maven.plugin.war.packaging.WarProjectPackagingTask;
 import org.apache.maven.plugin.war.util.WebappStructure;
 import org.apache.maven.plugin.war.util.WebappStructureSerializer;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.shared.filtering.MavenFileFilter;
 import org.apache.maven.shared.filtering.MavenFilteringException;
 import org.apache.maven.shared.filtering.MavenResourcesExecution;
 import org.apache.maven.shared.filtering.MavenResourcesFiltering;
+import org.codehaus.plexus.archiver.Archiver;
 import org.codehaus.plexus.archiver.jar.JarArchiver;
 import org.codehaus.plexus.archiver.manager.ArchiverManager;
 import org.codehaus.plexus.util.StringUtils;
@@ -75,20 +78,14 @@ public abstract class AbstractWarMojo
 
     /**
      * The Maven project.
-     *
-     * @parameter default-value="${project}"
-     * @required
-     * @readonly
      */
+    @Component
     private MavenProject project;
 
     /**
      * The directory containing compiled classes.
-     *
-     * @parameter default-value="${project.build.outputDirectory}"
-     * @required
-     * @readonly
      */
+    @Parameter( defaultValue = "${project.build.outputDirectory}", required = true, readonly = true )
     private File classesDirectory;
 
     /**
@@ -96,55 +93,46 @@ public abstract class AbstractWarMojo
      * parameter will make the compiled classes to be archived into a JAR file
      * and the classes directory will then be excluded from the webapp.
      *
-     * @parameter expression="${archiveClasses}" default-value="false"
      * @since 2.0.1
      */
+    @Parameter( property = "archiveClasses", defaultValue = "false" )
     private boolean archiveClasses;
 
     /**
      * The JAR archiver needed for archiving the classes directory into a JAR file under WEB-INF/lib.
-     *
-     * @component role="org.codehaus.plexus.archiver.Archiver" role-hint="jar"
-     * @required
      */
+    @Component( role = Archiver.class, hint = "jar" )
     private JarArchiver jarArchiver;
 
     /**
      * The directory where the webapp is built.
-     *
-     * @parameter default-value="${project.build.directory}/${project.build.finalName}"
-     * @required
      */
+    @Parameter( defaultValue = "${project.build.directory}/${project.build.finalName}", required = true )
     private File webappDirectory;
 
     /**
      * Single directory for extra files to include in the WAR. This is where
      * you place your JSP files.
-     *
-     * @parameter default-value="${basedir}/src/main/webapp"
-     * @required
      */
+    @Parameter( defaultValue = "${basedir}/src/main/webapp", required = true )
     private File warSourceDirectory;
 
     /**
      * The list of webResources we want to transfer.
-     *
-     * @parameter
      */
+    @Parameter
     private Resource[] webResources;
 
     /**
      * Filters (property files) to include during the interpolation of the pom.xml.
-
-     * @parameter
      */
+    @Parameter
     private List filters;
 
     /**
      * The path to the web.xml file to use.
-     *
-     * @parameter expression="${maven.war.webxml}"
      */
+    @Parameter( property = "maven.war.webxml" )
     private File webXml;
 
     /**
@@ -152,87 +140,75 @@ public abstract class AbstractWarMojo
      * the file name may be different for different servlet containers.
      * Apache Tomcat uses a configuration file named context.xml. The file will
      * be copied to the META-INF directory.
-     *
-     * @parameter expression="${maven.war.containerConfigXML}"
      */
+    @Parameter( property = "maven.war.containerConfigXML" )
     private File containerConfigXML;
 
     /**
      * Directory to unpack dependent WARs into if needed.
-     *
-     * @parameter default-value="${project.build.directory}/war/work"
-     * @required
      */
+    @Parameter( defaultValue = "${project.build.directory}/war/work", required = true )
     private File workDirectory;
 
     /**
      * The file name mapping to use when copying libraries and TLDs. If no file mapping is
      * set (default) the files are copied with their standard names.
      *
-     * @parameter
      * @since 2.1-alpha-1
      */
+    @Parameter
     private String outputFileNameMapping;
 
     /**
      * The file containing the webapp structure cache.
      *
-     * @parameter default-value="${project.build.directory}/war/work/webapp-cache.xml"
-     * @required
      * @since 2.1-alpha-1
      */
+    @Parameter( defaultValue = "${project.build.directory}/war/work/webapp-cache.xml", required = true )
     private File cacheFile;
 
     /**
      * Whether the cache should be used to save the status of the webapp
      * across multiple runs. Experimental feature so disabled by default.
      *
-     * @parameter expression="${useCache}" default-value="false"
      * @since 2.1-alpha-1
      */
+    @Parameter( property = "useCache", defaultValue = "false" )
     private boolean useCache = false;
 
     /**
-     * @component role="org.apache.maven.artifact.factory.ArtifactFactory"
-     * @required
-     * @readonly
      */
+    @Component( role = ArtifactFactory.class )
     private ArtifactFactory artifactFactory;
 
     /**
      * To look up Archiver/UnArchiver implementations.
-     *
-     * @component role="org.codehaus.plexus.archiver.manager.ArchiverManager"
-     * @required
      */
+    @Component( role = ArchiverManager.class )
     private ArchiverManager archiverManager;
 
     /**
-     * @component role="org.apache.maven.shared.filtering.MavenFileFilter" role-hint="default"
-     * @required
      */
+    @Component( role = MavenFileFilter.class, hint = "default" )
     private MavenFileFilter mavenFileFilter;
 
     /**
-     * @component role="org.apache.maven.shared.filtering.MavenResourcesFiltering" role-hint="default"
-     * @required
      */
+    @Component( role = MavenResourcesFiltering.class, hint = "default" )
     private MavenResourcesFiltering mavenResourcesFiltering;
 
     /**
      * The comma separated list of tokens to include when copying the content
      * of the warSourceDirectory.
-     *
-     * @parameter alias="includes" default-value="**"
      */
+    @Parameter( alias = "includes", defaultValue = "**" )
     private String warSourceIncludes;
 
     /**
      * The comma separated list of tokens to exclude when copying the content
      * of the warSourceDirectory.
-     *
-     * @parameter alias="excludes"
      */
+    @Parameter( alias = "excludes" )
     private String warSourceExcludes;
 
     /**
@@ -240,77 +216,74 @@ public abstract class AbstractWarMojo
      * a WAR overlay.
      * Default is '**'
      *
-     * @parameter
      * @deprecated Use &lt;overlay&gt;/&lt;includes&gt; instead
      */
+    @Parameter
     private String dependentWarIncludes = "**/**";
 
     /**
      * The comma separated list of tokens to exclude when doing
      * a WAR overlay.
      *
-     * @parameter
      * @deprecated Use &lt;overlay&gt;/&lt;excludes&gt; instead
      */
+    @Parameter
     private String dependentWarExcludes = "META-INF/**";
 
     /**
      * The overlays to apply.
      *
-     * @parameter
      * @since 2.1-alpha-1
      */
+    @Parameter
     private List overlays = new ArrayList();
 
     /**
      * A list of file extensions that should not be filtered.
      * <b>Will be used when filtering webResources and overlays.</b>
      *
-     * @parameter
      * @since 2.1-alpha-2
      */
+    @Parameter
     private List nonFilteredFileExtensions;
 
     /**
-     * @parameter default-value="${session}"
-     * @readonly
-     * @required
      * @since 2.1-alpha-2
      */
+    @Component
     private MavenSession session;
 
     /**
      * To filter deployment descriptors. <b>Disabled by default.</b>
      *
-     * @parameter expression="${maven.war.filteringDeploymentDescriptors}" default-value="false"
      * @since 2.1-alpha-2
      */
+    @Parameter( property = "maven.war.filteringDeploymentDescriptors", defaultValue = "false" )
     private boolean filteringDeploymentDescriptors = false;
 
     /**
      * To escape interpolated values with Windows path
      * <code>c:\foo\bar</code> will be replaced with <code>c:\\foo\\bar</code>.
      *
-     * @parameter expression="${maven.war.escapedBackslashesInFilePath}" default-value="false"
      * @since 2.1-alpha-2
      */
+    @Parameter( property = "maven.war.escapedBackslashesInFilePath", defaultValue = "false" )
     private boolean escapedBackslashesInFilePath = false;
 
     /**
      * Expression preceded with this String won't be interpolated.
      * <code>\${foo}</code> will be replaced with <code>${foo}</code>.
      *
-     * @parameter expression="${maven.war.escapeString}"
      * @since 2.1-beta-1
      */
+    @Parameter( property = "maven.war.escapeString" )
     protected String escapeString;
 
     /**
      * The archive configuration to use.
      * See <a href="http://maven.apache.org/shared/maven-archiver/index.html">Maven Archiver Reference</a>.
-     *
-     * @parameter
      */
+    @Parameter
     private MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
 
     private final WebappStructureSerializer webappStructureSerialier = new WebappStructureSerializer();

Modified: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarExplodedMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarExplodedMojo.java?rev=1355570&r1=1355569&r2=1355570&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarExplodedMojo.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarExplodedMojo.java Fri Jun 29 21:40:37 2012
@@ -21,16 +21,17 @@ package org.apache.maven.plugin.war;
 
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.ResolutionScope;
 
 /**
  * Create an exploded webapp in a specified directory.
  *
- * @goal exploded
- * @phase package
- * @threadSafe
- * @requiresDependencyResolution runtime
  * @version $Id$
  */
+@Mojo( name = "exploded", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true,
+       requiresDependencyResolution = ResolutionScope.RUNTIME )
 public class WarExplodedMojo
     extends AbstractWarMojo
 {

Modified: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarInPlaceMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarInPlaceMojo.java?rev=1355570&r1=1355569&r2=1355570&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarInPlaceMojo.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarInPlaceMojo.java Fri Jun 29 21:40:37 2012
@@ -21,15 +21,15 @@ package org.apache.maven.plugin.war;
 
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.ResolutionScope;
 
 /**
  * Generate the webapp in the WAR source directory.
  *
- * @goal inplace
- * @requiresDependencyResolution runtime
- * @threadSafe
  * @version $Id$
  */
+@Mojo( name = "inplace", requiresDependencyResolution = ResolutionScope.RUNTIME , threadSafe = true )
 public class WarInPlaceMojo
     extends AbstractWarMojo
 {

Modified: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarManifestMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarManifestMojo.java?rev=1355570&r1=1355569&r2=1355570&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarManifestMojo.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarManifestMojo.java Fri Jun 29 21:40:37 2012
@@ -22,6 +22,11 @@ package org.apache.maven.plugin.war;
 import org.apache.maven.archiver.MavenArchiver;
 import org.apache.maven.artifact.DependencyResolutionRequiredException;
 import org.apache.maven.plugin.MojoExecutionException;
+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.ResolutionScope;
+import org.codehaus.plexus.archiver.Archiver;
 import org.codehaus.plexus.archiver.jar.Manifest;
 import org.codehaus.plexus.archiver.jar.ManifestException;
 import org.codehaus.plexus.archiver.war.WarArchiver;
@@ -38,19 +43,16 @@ import java.io.PrintWriter;
  *
  * @author Mike Perham
  * @version $Id$
- * @goal manifest
- * @phase process-resources
- * @threadSafe
- * @requiresDependencyResolution runtime
  */
+@Mojo( name = "manifest", defaultPhase = LifecyclePhase.PROCESS_RESOURCES, threadSafe = true,
+       requiresDependencyResolution = ResolutionScope.RUNTIME )
 public class WarManifestMojo
     extends AbstractWarMojo
 {
     /**
      * The WAR archiver.
-     *
-     * @component role="org.codehaus.plexus.archiver.Archiver" roleHint="war"
      */
+    @Component( role = Archiver.class, hint = "war" )
     private WarArchiver warArchiver;
 
 

Modified: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java?rev=1355570&r1=1355569&r2=1355570&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java Fri Jun 29 21:40:37 2012
@@ -25,7 +25,13 @@ import org.apache.maven.artifact.Depende
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugin.war.util.ClassesPackager;
+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.MavenProjectHelper;
+import org.codehaus.plexus.archiver.Archiver;
 import org.codehaus.plexus.archiver.ArchiverException;
 import org.codehaus.plexus.archiver.jar.ManifestException;
 import org.codehaus.plexus.archiver.war.WarArchiver;
@@ -41,36 +47,29 @@ import java.util.Arrays;
  *
  * @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
  * @version $Id$
- * @goal war
- * @phase package
- * @threadSafe
- * @requiresDependencyResolution runtime
  */
+@Mojo( name = "war", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true,
+       requiresDependencyResolution = ResolutionScope.RUNTIME )
 public class WarMojo
     extends AbstractWarMojo
 {
     /**
      * The directory for the generated WAR.
-     *
-     * @parameter default-value="${project.build.directory}"
-     * @required
      */
+    @Parameter( defaultValue = "${project.build.directory}", required = true )
     private String outputDirectory;
 
     /**
      * The name of the generated WAR.
-     *
-     * @parameter default-value="${project.build.finalName}"
-     * @required
      */
+    @Parameter( defaultValue = "${project.build.finalName}", required = true )
     private String warName;
 
     /**
      * Classifier to add to the generated WAR. If given, the artifact will be an attachment instead.
      * The classifier will not be applied to the JAR file of the project - only to the WAR file.
-     *
-     * @parameter
      */
+    @Parameter
     private String classifier;
 
     /**
@@ -80,9 +79,9 @@ public class WarMojo
      * include and exclude specific pattern using the expression %regex[].
      * Hint: read the about (?!Pattern).
      *
-     * @parameter
      * @since 2.1-alpha-2
      */
+    @Parameter
     private String packagingExcludes;
 
     /**
@@ -92,29 +91,27 @@ public class WarMojo
      * Java Regular Expressions engine to include and exclude specific pattern
      * using the expression %regex[].
      *
-     * @parameter
      * @since 2.1-beta-1
      */
+    @Parameter
     private String packagingIncludes;
 
     /**
      * The WAR archiver.
-     *
-     * @component role="org.codehaus.plexus.archiver.Archiver" roleHint="war"
      */
+    @Component( role = Archiver.class, hint = "war" )
     private WarArchiver warArchiver;
 
     /**
-     * @component
      */
+    @Component
     private MavenProjectHelper projectHelper;
 
     /**
      * Whether this is the main artifact being built. Set to <code>false</code> if you don't want to install or
      * deploy it to the local repository instead of the default one in an execution.
-     *
-     * @parameter expression="${primaryArtifact}" default-value="true"
      */
+    @Parameter( property = "primaryArtifact", defaultValue = "true" )
     private boolean primaryArtifact = true;
 
     /**
@@ -122,16 +119,16 @@ public class WarMojo
      * if you want you WAR built without a <code>web.xml</code> file.
      * This may be useful if you are building an overlay that has no web.xml file.
      *
-     * @parameter expression="${failOnMissingWebXml}" default-value="true"
      * @since 2.1-alpha-2
      */
+    @Parameter( property = "failOnMissingWebXml", defaultValue = "true" )
     private boolean failOnMissingWebXml = true;
 
     /**
      * Whether classes (that is the content of the WEB-INF/classes directory) should be attached to the
      * project as an additional artifact.
      * <p>By default the
-     * classifier for the additional artifact is 'classes'. 
+     * classifier for the additional artifact is 'classes'.
      * You can change it with the
      * <code><![CDATA[<classesClassifier>someclassifier</classesClassifier>]]></code>
      * parameter.
@@ -144,17 +141,18 @@ public class WarMojo
      *   <version>myVersion</myVersion>
      *   <classifier>classes</classifier>
      * </dependency>]]></pre></p>
-     * @parameter default-value="false"
+     *
      * @since 2.1-alpha-2
      */
+    @Parameter( defaultValue = "false" )
     private boolean attachClasses = false;
 
     /**
      * The classifier to use for the attached classes artifact.
      *
-     * @parameter default-value="classes"
      * @since 2.1-alpha-2
      */
+    @Parameter( defaultValue = "classes" )
     private String classesClassifier = "classes";
 
     // ----------------------------------------------------------------------