You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2005/10/04 09:15:58 UTC

svn commit: r293557 - in /maven/components/trunk: maven-core-it/ maven-core-it/it0080/ maven-core-it/it0081/ maven-core-it/it0081/test-component-c/ maven-core-it/it0081/test-plugin/ maven-core-it/it0081/test-plugin/src/ maven-core-it/it0081/test-plugin...

Author: brett
Date: Tue Oct  4 00:15:36 2005
New Revision: 293557

URL: http://svn.apache.org/viewcvs?rev=293557&view=rev
Log:
PR: MNG-956
allow the addition of <dependencies> inside a <plugin> element to introduce plugin specific extensions.

Added:
    maven/components/trunk/maven-core-it/it0081/   (with props)
    maven/components/trunk/maven-core-it/it0081/expected-results.txt   (with props)
    maven/components/trunk/maven-core-it/it0081/goals.txt   (with props)
    maven/components/trunk/maven-core-it/it0081/pom.xml   (with props)
    maven/components/trunk/maven-core-it/it0081/test-component-c/   (with props)
    maven/components/trunk/maven-core-it/it0081/test-component-c/pom.xml   (with props)
    maven/components/trunk/maven-core-it/it0081/test-plugin/   (with props)
    maven/components/trunk/maven-core-it/it0081/test-plugin/pom.xml   (with props)
    maven/components/trunk/maven-core-it/it0081/test-plugin/src/
    maven/components/trunk/maven-core-it/it0081/test-plugin/src/main/
    maven/components/trunk/maven-core-it/it0081/test-plugin/src/main/java/
    maven/components/trunk/maven-core-it/it0081/test-plugin/src/main/java/org/
    maven/components/trunk/maven-core-it/it0081/test-plugin/src/main/java/org/apache/
    maven/components/trunk/maven-core-it/it0081/test-plugin/src/main/java/org/apache/maven/
    maven/components/trunk/maven-core-it/it0081/test-plugin/src/main/java/org/apache/maven/plugin/
    maven/components/trunk/maven-core-it/it0081/test-plugin/src/main/java/org/apache/maven/plugin/coreit/
    maven/components/trunk/maven-core-it/it0081/test-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java   (with props)
Modified:
    maven/components/trunk/maven-core-it/README.txt
    maven/components/trunk/maven-core-it/integration-tests.txt
    maven/components/trunk/maven-core-it/it0080/   (props changed)
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
    maven/components/trunk/maven-model/maven.mdo
    maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java

Modified: maven/components/trunk/maven-core-it/README.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/README.txt?rev=293557&r1=293556&r2=293557&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/README.txt (original)
+++ maven/components/trunk/maven-core-it/README.txt Tue Oct  4 00:15:36 2005
@@ -220,6 +220,8 @@
 it0080: Test that depending on a WAR doesn't also get its dependencies
         transitively.
 
+it0081: Test per-plugin dependencies.
+
 -------------------------------------------------------------------------------
 
 - generated sources

Modified: maven/components/trunk/maven-core-it/integration-tests.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/integration-tests.txt?rev=293557&r1=293556&r2=293557&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/integration-tests.txt (original)
+++ maven/components/trunk/maven-core-it/integration-tests.txt Tue Oct  4 00:15:36 2005
@@ -1,3 +1,4 @@
+it0081
 it0080
 it0079
 it0078

Propchange: maven/components/trunk/maven-core-it/it0080/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Oct  4 00:15:36 2005
@@ -0,0 +1 @@
+log.txt

Propchange: maven/components/trunk/maven-core-it/it0081/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Oct  4 00:15:36 2005
@@ -0,0 +1,2 @@
+log.txt
+target

Added: maven/components/trunk/maven-core-it/it0081/expected-results.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0081/expected-results.txt?rev=293557&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0081/expected-results.txt (added)
+++ maven/components/trunk/maven-core-it/it0081/expected-results.txt Tue Oct  4 00:15:36 2005
@@ -0,0 +1 @@
+test-component-c/target/org.apache.maven.wagon.providers.ftp.FtpWagon

Propchange: maven/components/trunk/maven-core-it/it0081/expected-results.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-core-it/it0081/expected-results.txt
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-core-it/it0081/goals.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0081/goals.txt?rev=293557&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0081/goals.txt (added)
+++ maven/components/trunk/maven-core-it/it0081/goals.txt Tue Oct  4 00:15:36 2005
@@ -0,0 +1 @@
+install

Propchange: maven/components/trunk/maven-core-it/it0081/goals.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-core-it/it0081/goals.txt
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-core-it/it0081/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0081/pom.xml?rev=293557&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0081/pom.xml (added)
+++ maven/components/trunk/maven-core-it/it0081/pom.xml Tue Oct  4 00:15:36 2005
@@ -0,0 +1,13 @@
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>test</groupId>
+  <artifactId>test-components</artifactId>
+  <version>0.1</version>
+  <name>Test Components</name>
+  <packaging>pom</packaging>
+
+  <modules>
+    <module>test-component-c</module>
+    <module>test-plugin</module>
+  </modules>
+</project>

Propchange: maven/components/trunk/maven-core-it/it0081/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-core-it/it0081/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Propchange: maven/components/trunk/maven-core-it/it0081/test-component-c/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Oct  4 00:15:36 2005
@@ -0,0 +1 @@
+target

Added: maven/components/trunk/maven-core-it/it0081/test-component-c/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0081/test-component-c/pom.xml?rev=293557&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0081/test-component-c/pom.xml (added)
+++ maven/components/trunk/maven-core-it/it0081/test-component-c/pom.xml Tue Oct  4 00:15:36 2005
@@ -0,0 +1,37 @@
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <artifactId>test-components</artifactId>
+    <groupId>test</groupId>
+    <version>0.1</version>
+  </parent>
+
+  <groupId>test</groupId>
+  <artifactId>test-component-c</artifactId>
+  <version>0.1</version>
+  <name>Test Component C</name>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>test</groupId>
+        <artifactId>test-plugin</artifactId>
+        <version>0.1</version>
+        <dependencies>
+          <dependency>
+            <groupId>org.apache.maven.wagon</groupId>
+            <artifactId>wagon-ftp</artifactId>
+            <version>1.0-alpha-4</version>
+          </dependency>
+        </dependencies>
+        <executions>
+          <execution>
+            <goals>
+              <goal>test</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/components/trunk/maven-core-it/it0081/test-component-c/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-core-it/it0081/test-component-c/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Propchange: maven/components/trunk/maven-core-it/it0081/test-plugin/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Oct  4 00:15:36 2005
@@ -0,0 +1 @@
+target

Added: maven/components/trunk/maven-core-it/it0081/test-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0081/test-plugin/pom.xml?rev=293557&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0081/test-plugin/pom.xml (added)
+++ maven/components/trunk/maven-core-it/it0081/test-plugin/pom.xml Tue Oct  4 00:15:36 2005
@@ -0,0 +1,21 @@
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <artifactId>test-components</artifactId>
+    <groupId>test</groupId>
+    <version>0.1</version>
+  </parent>
+
+  <groupId>test</groupId>
+  <artifactId>test-plugin</artifactId>
+  <packaging>maven-plugin</packaging>
+  <version>0.1</version>
+  <name>Test Plugin</name>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0-beta-1</version>
+    </dependency>
+  </dependencies>
+</project>

Propchange: maven/components/trunk/maven-core-it/it0081/test-plugin/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-core-it/it0081/test-plugin/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-core-it/it0081/test-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0081/test-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java?rev=293557&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0081/test-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java (added)
+++ maven/components/trunk/maven-core-it/it0081/test-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java Tue Oct  4 00:15:36 2005
@@ -0,0 +1,75 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+/**
+ * test goal.
+ *
+ * @goal test
+ * @phase test
+ */
+public class CoreItMojo
+    extends AbstractMojo
+{
+    /**
+     * @parameter expression="${project.build.directory}"
+     * @required
+     */
+    private String outputDirectory;
+
+    /**
+     * @component role="org.apache.maven.wagon.Wagon" roleHint="ftp"
+     */
+    private Object wagon;
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        touch( new File( outputDirectory ), wagon.getClass().getName() );
+    }
+
+    private static void touch( File dir, String file )
+        throws MojoExecutionException
+    {
+        try
+        {
+             if ( !dir.exists() )
+             {
+                 dir.mkdirs();
+             }
+             
+             File touch = new File( dir, file );
+     
+             FileWriter w = new FileWriter( touch );
+             
+             w.write( file );
+             
+             w.close();
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Error touching file", e );
+        }
+    }
+}

Propchange: maven/components/trunk/maven-core-it/it0081/test-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-core-it/it0081/test-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=293557&r1=293556&r2=293557&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Tue Oct  4 00:15:36 2005
@@ -49,6 +49,7 @@
 import org.apache.maven.project.MavenProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
 import org.apache.maven.project.artifact.ActiveProjectArtifact;
+import org.apache.maven.project.artifact.MavenMetadataSource;
 import org.apache.maven.project.path.PathTranslator;
 import org.apache.maven.reporting.MavenReport;
 import org.apache.maven.settings.Settings;
@@ -66,7 +67,6 @@
 import org.codehaus.plexus.context.Context;
 import org.codehaus.plexus.context.ContextException;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.logging.LoggerManager;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
 import org.codehaus.plexus.util.StringUtils;
@@ -85,7 +85,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.Properties;
 
 public class DefaultPluginManager
     extends AbstractLogEnabled
@@ -304,6 +303,17 @@
         // later when the plugin is first invoked. Retrieving this artifact will in turn allow us to
         // transitively resolve its dependencies, and add them to the plugin container...
         addedPlugin.setArtifacts( Collections.singletonList( pluginArtifact ) );
+
+        try
+        {
+            Set artifacts = MavenMetadataSource.createArtifacts( artifactFactory, plugin.getDependencies(), null, null,
+                                                             project.getProjectReferences() );
+            addedPlugin.setIntroducedDependencyArtifacts( artifacts );
+        }
+        catch ( InvalidVersionSpecificationException e )
+        {
+            throw new PluginManagerException( "Unable to get one of the plugins additional dependencies", e );
+        }
     }
 
     // ----------------------------------------------------------------------
@@ -506,10 +516,7 @@
         return pluginContainer;
     }
 
-    private Mojo getConfiguredMojo( MavenSession session,
-                                    Xpp3Dom dom,
-                                    MavenProject project,
-                                    boolean report,
+    private Mojo getConfiguredMojo( MavenSession session, Xpp3Dom dom, MavenProject project, boolean report,
                                     MojoExecution mojoExecution )
         throws ComponentLookupException, PluginConfigurationException, PluginManagerException
     {
@@ -592,7 +599,9 @@
                 ResolutionGroup resolutionGroup = artifactMetadataSource.retrieve( pluginArtifact, localRepository,
                                                                                    project.getPluginArtifactRepositories() );
 
-                Set dependencies = resolutionGroup.getArtifacts();
+                Set dependencies = new HashSet( resolutionGroup.getArtifacts() );
+
+                dependencies.addAll( pluginDescriptor.getIntroducedDependencyArtifacts() );
 
                 ArtifactResolutionResult result = artifactResolver.resolveTransitively( dependencies, pluginArtifact,
                                                                                         localRepository,
@@ -1041,13 +1050,14 @@
         }
         catch ( ComponentConfigurationException e )
         {
-            throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), "Unable to parse the created DOM for plugin configuration", e );
+            throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(),
+                                                    "Unable to parse the created DOM for plugin configuration", e );
         }
         catch ( ComponentLookupException e )
         {
-            throw new PluginConfigurationException(mojoDescriptor.getPluginDescriptor(),
-                                                   "Unable to retrieve component configurator for plugin configuration",
-                                                   e );
+            throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(),
+                                                    "Unable to retrieve component configurator for plugin configuration",
+                                                    e );
         }
         finally
         {

Modified: maven/components/trunk/maven-model/maven.mdo
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-model/maven.mdo?rev=293557&r1=293556&r2=293557&view=diff
==============================================================================
--- maven/components/trunk/maven-model/maven.mdo (original)
+++ maven/components/trunk/maven-model/maven.mdo Tue Oct  4 00:15:36 2005
@@ -2388,6 +2388,15 @@
           </association>
         </field>
         <field>
+          <name>dependencies</name>
+          <description>Additional dependencies that this project needs to introduce to the plugin</description>
+          <version>4.0.0</version>
+          <association>
+            <type>Dependency</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+        <field>
           <name>goals</name>
           <version>4.0.0</version>
           <description><![CDATA[
@@ -2543,7 +2552,7 @@
           <version>4.0.0</version>
           <code><![CDATA[
     java.util.Map reportPluginMap;
-    
+
     public void flushReportPluginMap()
     {
         this.reportPluginMap = null;
@@ -2575,7 +2584,7 @@
       <superClass>ModelBase</superClass>
       <version>4.0.0</version>
       <description><![CDATA[
-        Modifications to the build process which is keyed on some 
+        Modifications to the build process which is keyed on some
         sort of environmental parameter.
       ]]></description>
       <fields>
@@ -2613,17 +2622,17 @@
     // We don't want this to be parseable...it's sort of 'hidden'
     // default source for this profile is in the pom itself.
     private String source = "pom";
-    
+
     public void setSource( String source )
     {
         this.source = source;
     }
-    
+
     public String getSource()
     {
         return source;
     }
-    
+
     public String toString()
     {
         return "Profile {id: " + getId() + ", source: " + getSource() + "}";
@@ -2636,7 +2645,7 @@
       <name>Activation</name>
       <version>4.0.0</version>
       <description><![CDATA[
-        The conditions within the build runtime environment which will trigger 
+        The conditions within the build runtime environment which will trigger
         the automatic inclusion of the parent build profile.
       ]]></description>
       <fields>
@@ -2690,7 +2699,7 @@
       <name>ActivationProperty</name>
       <version>4.0.0</version>
       <description><![CDATA[
-        This is the property specification used to activate a profile. If the value field is empty, 
+        This is the property specification used to activate a profile. If the value field is empty,
         then the existence of the named property will activate the profile, otherwise it does a case-sensitive
         match against the property value as well.
       ]]></description>

Modified: maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java?rev=293557&r1=293556&r2=293557&view=diff
==============================================================================
--- maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java (original)
+++ maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java Tue Oct  4 00:15:36 2005
@@ -33,6 +33,9 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
+import java.util.Collection;
+import java.util.Collections;
 
 /**
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
@@ -64,6 +67,8 @@
     // calculated on-demand.
     private Map artifactMap;
 
+    private Set introducedDependencyArtifacts;
+
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -214,18 +219,18 @@
     public void setArtifacts( List artifacts )
     {
         this.artifacts = artifacts;
-        
+
         // clear the calculated artifactMap
         artifactMap = null;
     }
-    
+
     public Map getArtifactMap()
     {
         if ( artifactMap == null )
         {
             artifactMap = ArtifactUtils.artifactMapByVersionlessId( getArtifacts() );
         }
-        
+
         return artifactMap;
     }
 
@@ -308,4 +313,13 @@
         return classRealm;
     }
 
+    public void setIntroducedDependencyArtifacts( Set introducedDependencyArtifacts )
+    {
+        this.introducedDependencyArtifacts = introducedDependencyArtifacts;
+    }
+
+    public Set getIntroducedDependencyArtifacts()
+    {
+        return introducedDependencyArtifacts != null ? introducedDependencyArtifacts : Collections.EMPTY_SET;
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org