You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by pg...@apache.org on 2009/09/10 21:39:22 UTC

svn commit: r813560 - /maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/CopyDependenciesMojo.java

Author: pgier
Date: Thu Sep 10 19:39:22 2009
New Revision: 813560

URL: http://svn.apache.org/viewvc?rev=813560&view=rev
Log:
[MDEP-164] If copyPom is set to true, poms should be copied regardless of whether the jar file already exists.

Modified:
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/CopyDependenciesMojo.java

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/CopyDependenciesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/CopyDependenciesMojo.java?rev=813560&r1=813559&r2=813560&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/CopyDependenciesMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/CopyDependenciesMojo.java Thu Sep 10 19:39:22 2009
@@ -103,13 +103,19 @@
 				throw new MojoExecutionException("Could not create outputDirectory repository", e);
 			}
         }
-
-        artifacts = dss.getSkippedDependencies();
-        for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+    	
+        Set skippedArtifacts = dss.getSkippedDependencies();
+        for ( Iterator i = skippedArtifacts.iterator(); i.hasNext(); )
         {
             Artifact artifact = (Artifact) i.next();
             getLog().info( artifact.getFile().getName() + " already exists in destination." );
         }
+        
+        if (  isCopyPom() )
+        {
+            copyPoms( getOutputDirectory(), artifacts, this.stripVersion );
+            copyPoms( getOutputDirectory(), skippedArtifacts, this.stripVersion );  // Artifacts that already exist may not already have poms.
+        }
     }
 
     private void installArtifact( Artifact artifact, ArtifactRepository targetRepository) 
@@ -184,17 +190,28 @@
         File destFile = new File( destDir, destFileName );
 
         copyFile( artifact.getFile(), destFile );
-        // Copy POM if asked
-        if ( isCopyPom() )
+    }
+    
+    /**
+     * Copy the pom files associated with the artifacts.
+     */
+    public void copyPoms( File destDir, Set artifacts, boolean removeVersion ) throws MojoExecutionException
+    
+    {
+        Iterator iter = artifacts.iterator();
+        while ( iter.hasNext() )
         {
-            // Create the pom
+            Artifact artifact = (Artifact)iter.next();
             Artifact pomArtifact = getResolvedPomArtifact( artifact );
             
             // Copy the pom
             if ( pomArtifact.getFile() != null && pomArtifact.getFile().exists() )
             {
                 File pomDestFile = new File( destDir, DependencyUtil.getFormattedFileName( pomArtifact, removeVersion ) );
-                copyFile( pomArtifact.getFile(), pomDestFile );
+                if ( ! pomDestFile.exists() )
+                {
+                    copyFile( pomArtifact.getFile(), pomDestFile );
+                }
             }
         }
     }