You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2007/07/31 18:30:17 UTC

svn commit: r561381 - in /maven/plugins/trunk/maven-assembly-plugin: ./ maven-assembly-artifact-types/src/main/resources/META-INF/plexus/ src/main/java/org/apache/maven/plugin/assembly/artifact/ src/main/java/org/apache/maven/plugin/assembly/mojos/

Author: jdcasey
Date: Tue Jul 31 09:30:14 2007
New Revision: 561381

URL: http://svn.apache.org/viewvc?view=rev&rev=561381
Log:
Fixing assembly-descriptor and assembly-component handlers/lifecycles to once again have a classifier, and changing the associated attach mojos to attach these descriptors to the main project artifact, which is now the pom itself...rather than setting the main project artifact to the descriptor, which leaves off the classifier.

Modified:
    maven/plugins/trunk/maven-assembly-plugin/maven-assembly-artifact-types/src/main/resources/META-INF/plexus/components.xml
    maven/plugins/trunk/maven-assembly-plugin/pom.xml
    maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/artifact/DefaultDependencyResolver.java
    maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AttachAssemblyDescriptorMojo.java
    maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AttachComponentDescriptorMojo.java

Modified: maven/plugins/trunk/maven-assembly-plugin/maven-assembly-artifact-types/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/maven-assembly-artifact-types/src/main/resources/META-INF/plexus/components.xml?view=diff&rev=561381&r1=561380&r2=561381
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/maven-assembly-artifact-types/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/plugins/trunk/maven-assembly-plugin/maven-assembly-artifact-types/src/main/resources/META-INF/plexus/components.xml Tue Jul 31 09:30:14 2007
@@ -6,6 +6,7 @@
       <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
       <configuration>
         <packaging>assembly-component</packaging>
+        <classifier>assembly-component</classifier>
         <extension>xml</extension>
         <type>assembly-component</type>
         <addedToClasspath>false</addedToClasspath>
@@ -37,6 +38,7 @@
       <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
       <configuration>
         <packaging>assembly-descriptor</packaging>
+        <classifier>assembly-descriptor</classifier>
         <extension>xml</extension>
         <type>assembly-descriptor</type>
         <addedToClasspath>false</addedToClasspath>

Modified: maven/plugins/trunk/maven-assembly-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/pom.xml?view=diff&rev=561381&r1=561380&r2=561381
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-assembly-plugin/pom.xml Tue Jul 31 09:30:14 2007
@@ -103,6 +103,12 @@
               <descriptors>
                 <descriptor>${project.build.directory}/generated-resources/plexus/META-INF/plexus/components.xml</descriptor>
                 <descriptor>src/main/resources/META-INF/plexus/components.xml</descriptor>
+                
+                <!--  This is a separate artifact also, but we need access to 
+                      the ArtifactHandlers from the assembly plugin to enable 
+                      attachment of these artifacts without requiring weird 
+                      configurations. -->
+                <descriptor>maven-assembly-artifact-types/src/main/resources/META-INF/plexus/components.xml</descriptor>
               </descriptors>
             </configuration>
             <phase>generate-resources</phase>

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/artifact/DefaultDependencyResolver.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/artifact/DefaultDependencyResolver.java?view=diff&rev=561381&r1=561380&r2=561381
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/artifact/DefaultDependencyResolver.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/artifact/DefaultDependencyResolver.java Tue Jul 31 09:30:14 2007
@@ -20,10 +20,17 @@
 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
 import org.apache.maven.project.artifact.MavenMetadataSource;
 import org.apache.maven.shared.artifact.filter.ScopeArtifactFilter;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.context.Context;
+import org.codehaus.plexus.context.ContextException;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -38,12 +45,17 @@
  * @author jdcasey
  */
 public class DefaultDependencyResolver
-    extends AbstractLogEnabled implements DependencyResolver
+    extends AbstractLogEnabled implements DependencyResolver, Contextualizable
 {
 
-    /**
-     * @plexus.requirement
-     */
+    private static final String[] PREFERRED_RESOLVER_HINTS = {
+      "project-cache-aware", // Provided in Maven 2.1-SNAPSHOT
+      "default"
+    };
+
+    // Commenting this out as a component requirement, so we can look for the new
+    // resolver in maven 2.1-snapshot, then fail back to the default one.
+//     * @plexus.requirement
     private ArtifactResolver resolver;
 
     /**
@@ -199,5 +211,44 @@
             map = Collections.EMPTY_MAP;
         }
         return map;
+    }
+
+    public void contextualize( Context context )
+        throws ContextException
+    {
+        PlexusContainer container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
+
+        for ( int i = 0; i < PREFERRED_RESOLVER_HINTS.length; i++ )
+        {
+            String hint = PREFERRED_RESOLVER_HINTS[i];
+
+            try
+            {
+                resolver = (ArtifactResolver) container.lookup( ArtifactResolver.ROLE, hint );
+                break;
+            }
+            catch ( ComponentLookupException e )
+            {
+                getLogger().debug( "Cannot find ArtifactResolver with hint: " + hint, e );
+            }
+        }
+
+        if ( resolver == null )
+        {
+            try
+            {
+                resolver = (ArtifactResolver) container.lookup( ArtifactResolver.ROLE );
+            }
+            catch ( ComponentLookupException e )
+            {
+                getLogger().debug( "Cannot find ArtifactResolver with no hint.", e );
+            }
+        }
+
+        if ( resolver == null )
+        {
+            throw new ContextException( "Failed to lookup a valid ArtifactResolver implementation. Tried hints:\n"
+                                        + Arrays.asList( PREFERRED_RESOLVER_HINTS ) );
+        }
     }
 }

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AttachAssemblyDescriptorMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AttachAssemblyDescriptorMojo.java?view=diff&rev=561381&r1=561380&r2=561381
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AttachAssemblyDescriptorMojo.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AttachAssemblyDescriptorMojo.java Tue Jul 31 09:30:14 2007
@@ -1,5 +1,6 @@
 package org.apache.maven.plugin.assembly.mojos;
 
+import org.apache.maven.artifact.handler.ArtifactHandler;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -23,15 +24,6 @@
     private File assemblyDescriptor;
 
     /**
-     * If set, component descriptor will be attached to the main project
-     * artifact using this classifier, rather than becoming the artifact's
-     * backing file.
-     *
-     * @parameter
-     */
-    private String attachmentClassifier;
-
-    /**
      * @parameter default-value="${project}"
      * @required
      * @readonly
@@ -39,6 +31,11 @@
     private MavenProject project;
 
     /**
+     * @component role-hint="assembly-descriptor"
+     */
+    private ArtifactHandler handler;
+
+    /**
      * @component
      */
     private MavenProjectHelper projectHelper;
@@ -46,14 +43,9 @@
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
-        if ( attachmentClassifier != null )
-        {
-            projectHelper.attachArtifact( project, assemblyDescriptor, attachmentClassifier );
-        }
-        else
-        {
-            project.getArtifact().setFile( assemblyDescriptor );
-        }
+        File pomFile = project.getFile();
+        project.getArtifact().setFile( pomFile );
+        projectHelper.attachArtifact( project, assemblyDescriptor, handler.getClassifier() );
     }
 
 }

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AttachComponentDescriptorMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AttachComponentDescriptorMojo.java?view=diff&rev=561381&r1=561380&r2=561381
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AttachComponentDescriptorMojo.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AttachComponentDescriptorMojo.java Tue Jul 31 09:30:14 2007
@@ -1,5 +1,6 @@
 package org.apache.maven.plugin.assembly.mojos;
 
+import org.apache.maven.artifact.handler.ArtifactHandler;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -23,15 +24,6 @@
     private File componentDescriptor;
 
     /**
-     * If set, component descriptor will be attached to the main project
-     * artifact using this classifier, rather than becoming the artifact's
-     * backing file.
-     *
-     * @parameter
-     */
-    private String attachmentClassifier;
-
-    /**
      * @parameter default-value="${project}"
      * @required
      * @readonly
@@ -39,6 +31,11 @@
     private MavenProject project;
 
     /**
+     * @component role-hint="assembly-component"
+     */
+    private ArtifactHandler handler;
+
+    /**
      * @component
      */
     private MavenProjectHelper projectHelper;
@@ -46,14 +43,9 @@
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
-        if ( attachmentClassifier != null )
-        {
-            projectHelper.attachArtifact( project, componentDescriptor, attachmentClassifier );
-        }
-        else
-        {
-            project.getArtifact().setFile( componentDescriptor );
-        }
+        File pomFile = project.getFile();
+        project.getArtifact().setFile( pomFile );
+        projectHelper.attachArtifact( project, componentDescriptor, handler.getClassifier() );
     }
 
 }