You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2010/05/01 00:58:30 UTC

svn commit: r939868 - in /maven/plugins/trunk/maven-invoker-plugin/src: it/install-extra-artifacts/pom.xml it/install-extra-artifacts/verify.bsh main/java/org/apache/maven/plugin/invoker/InstallMojo.java

Author: bentmann
Date: Fri Apr 30 22:58:30 2010
New Revision: 939868

URL: http://svn.apache.org/viewvc?rev=939868&view=rev
Log:
[MINVOKER-102] Provide a way to install Extra dependencies

o Added support for relocation of root artifact

Modified:
    maven/plugins/trunk/maven-invoker-plugin/src/it/install-extra-artifacts/pom.xml
    maven/plugins/trunk/maven-invoker-plugin/src/it/install-extra-artifacts/verify.bsh
    maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java

Modified: maven/plugins/trunk/maven-invoker-plugin/src/it/install-extra-artifacts/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/install-extra-artifacts/pom.xml?rev=939868&r1=939867&r2=939868&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/install-extra-artifacts/pom.xml (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/install-extra-artifacts/pom.xml Fri Apr 30 22:58:30 2010
@@ -50,6 +50,8 @@ under the License.
             <extraArtifact>org.apache.maven.plugins:maven-clean-plugin:2.4:maven-plugin</extraArtifact>
             <!-- gid:aid:version:type:classifier -->
             <extraArtifact>org.apache.maven.plugins:maven-clean-plugin:2.4:jar:javadoc</extraArtifact>
+            <!-- relocated -->
+            <extraArtifact>jdom:jdom:1.1</extraArtifact>
           </extraArtifacts>
         </configuration>
         <executions>

Modified: maven/plugins/trunk/maven-invoker-plugin/src/it/install-extra-artifacts/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/install-extra-artifacts/verify.bsh?rev=939868&r1=939867&r2=939868&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/install-extra-artifacts/verify.bsh (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/install-extra-artifacts/verify.bsh Fri Apr 30 22:58:30 2010
@@ -23,6 +23,9 @@ try
         "org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.pom",
         "junit/junit/3.8.2/junit-3.8.2.jar",
         "junit/junit/3.8.2/junit-3.8.2.pom",
+        "jdom/jdom/1.1/jdom-1.1.pom",
+        "org/jdom/jdom/1.1/jdom-1.1.pom",
+        "org/jdom/jdom/1.1/jdom-1.1.jar",
     };
     for ( String file : files )
     {
@@ -32,6 +35,10 @@ try
         {
             throw new IllegalStateException( "Missing: " + stagedFile );
         }
+        if ( file.endsWith( "jdom-1.1.jar" ) && stagedFile.length() < 1024 * 10 )
+        {
+            throw new IllegalStateException( "Corrupt: " + stagedFile );
+        }
     }
 }
 catch( Throwable t )

Modified: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java?rev=939868&r1=939867&r2=939868&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java Fri Apr 30 22:58:30 2010
@@ -522,6 +522,8 @@ public class InstallMojo
     private void copyArtifact( Artifact artifact, ArtifactRepository testRepository )
         throws MojoExecutionException
     {
+        copyPoms( artifact, testRepository );
+
         Artifact depArtifact =
             artifactFactory.createArtifactWithClassifier( artifact.getGroupId(), artifact.getArtifactId(),
                                                           artifact.getBaseVersion(), artifact.getType(),
@@ -529,22 +531,23 @@ public class InstallMojo
 
         File artifactFile = artifact.getFile();
 
+        copyArtifact( artifactFile, depArtifact, testRepository );
+    }
+
+    private void copyPoms( Artifact artifact, ArtifactRepository testRepository )
+        throws MojoExecutionException
+    {
         Artifact pomArtifact =
-            artifactFactory.createProjectArtifact( depArtifact.getGroupId(), depArtifact.getArtifactId(),
-                                                   depArtifact.getBaseVersion() );
+            artifactFactory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(),
+                                                   artifact.getBaseVersion() );
 
         File pomFile = new File( localRepository.getBasedir(), localRepository.pathOf( pomArtifact ) );
 
         if ( pomFile.isFile() )
         {
-            if ( !pomArtifact.getId().equals( depArtifact.getId() ) )
-            {
-                copyArtifact( pomFile, pomArtifact, testRepository );
-            }
+            copyArtifact( pomFile, pomArtifact, testRepository );
             copyParentPoms( pomFile, testRepository );
         }
-
-        copyArtifact( artifactFile, depArtifact, testRepository );
     }
 
     /**
@@ -611,6 +614,10 @@ public class InstallMojo
                 throw new MojoExecutionException( "Invalid artifact " + extraArtifacts[i] );
             }
 
+            String groupId = gav[0];
+            String artifactId = gav[1];
+            String version = gav[2];
+
             String type = "jar";
             if ( gav.length > 3 )
             {
@@ -636,12 +643,20 @@ public class InstallMojo
             Artifact artifact = null;
             try
             {
-                artifact = artifactFactory.createArtifactWithClassifier( gav[0], gav[1], gav[2], type, classifier );
+                artifact = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier );
 
                 ArtifactResolutionResult arr =
                     resolver.resolveTransitively( Collections.singleton( artifact ), originatingArtifact,
                                                   remoteRepositories, localRepository, artifactMetadataSource );
 
+                if ( !groupId.equals( artifact.getGroupId() ) || !artifactId.equals( artifact.getArtifactId() )
+                    || !version.equals( artifact.getVersion() ) )
+                {
+                    artifact =
+                        artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier );
+                    copyPoms( artifact, testRepository );
+                }
+
                 for ( Iterator iterator = arr.getArtifacts().iterator(); iterator.hasNext(); )
                 {
                     copyArtifact( (Artifact) iterator.next(), testRepository );