maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r1055234 - in /maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install: AbstractInstallMojo.java InstallFileMojo.java InstallMojo.java
Date Tue, 04 Jan 2011 22:57:09 GMT
Author: bentmann
Date: Tue Jan  4 22:57:08 2011
New Revision: 1055234

URL: http://svn.apache.org/viewvc?rev=1055234&view=rev
Log:
[MINSTALL-81] Checksums of metadata files are not always correct in case of attached artifacts

Modified:
    maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/AbstractInstallMojo.java
    maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java
    maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java

Modified: maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/AbstractInstallMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/AbstractInstallMojo.java?rev=1055234&r1=1055233&r2=1055234&view=diff
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/AbstractInstallMojo.java
(original)
+++ maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/AbstractInstallMojo.java
Tue Jan  4 22:57:08 2011
@@ -118,17 +118,18 @@ public abstract class AbstractInstallMoj
     }
 
     /**
-     * Installs the checksums for the specified artifact (and its metadata files) if this
has been enabled in the plugin
-     * configuration. This method creates checksums for files that have already been installed
to the local repo to
-     * account for on-the-fly generated/updated files. For example, in Maven 2.0.4- the
-     * <code>ProjectArtifactMetadata</code> did not install the original POM
file (cf. MNG-2820). While the plugin
-     * currently requires Maven 2.0.6, we continue to hash the installed POM for robustness
with regard to future
-     * changes like re-introducing some kind of POM filtering.
-     *
+     * Installs the checksums for the specified artifact if this has been enabled in the
plugin configuration. This
+     * method creates checksums for files that have already been installed to the local repo
to account for on-the-fly
+     * generated/updated files. For example, in Maven 2.0.4- the <code>ProjectArtifactMetadata</code>
did not install
+     * the original POM file (cf. MNG-2820). While the plugin currently requires Maven 2.0.6,
we continue to hash the
+     * installed POM for robustness with regard to future changes like re-introducing some
kind of POM filtering.
+     * 
      * @param artifact The artifact for which to create checksums, must not be <code>null</code>.
+     * @param metadataFiles The set where additional metadata files will be registered for
later checksum installation,
+     *            must not be <code>null</code>.
      * @throws MojoExecutionException If the checksums could not be installed.
      */
-    protected void installChecksums( Artifact artifact )
+    protected void installChecksums( Artifact artifact, Collection metadataFiles )
         throws MojoExecutionException
     {
         if ( !createChecksum )
@@ -146,12 +147,28 @@ public abstract class AbstractInstallMoj
             {
                 ArtifactMetadata metadata = (ArtifactMetadata) it.next();
                 File metadataFile = getLocalRepoFile( metadata );
-                installChecksums( metadataFile );
+                metadataFiles.add( metadataFile );
             }
         }
     }
 
     /**
+     * Installs the checksums for the specified metadata files.
+     * 
+     * @param metadataFiles The collection of metadata files to install checksums for, must
not be <code>null</code>.
+     * @throws MojoExecutionException If the checksums could not be installed.
+     */
+    protected void installChecksums( Collection metadataFiles )
+        throws MojoExecutionException
+    {
+        for ( Iterator it = metadataFiles.iterator(); it.hasNext(); )
+        {
+            File metadataFile = (File) it.next();
+            installChecksums( metadataFile );
+        }
+    }
+
+    /**
      * Installs the checksums for the specified file (if it exists).
      *
      * @param installedFile The path to the already installed file in the local repo for
which to generate checksums,

Modified: maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java?rev=1055234&r1=1055233&r2=1055234&view=diff
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java
(original)
+++ maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java
Tue Jan  4 22:57:08 2011
@@ -44,6 +44,8 @@ import java.io.IOException;
 import java.io.Reader;
 import java.io.Writer;
 import java.net.MalformedURLException;
+import java.util.Collection;
+import java.util.LinkedHashSet;
 import java.util.Map;
 
 /**
@@ -245,12 +247,14 @@ public class InstallFileMojo
             artifact.setRelease( true );
         }
 
+        Collection metadataFiles = new LinkedHashSet();
+
         // TODO: maybe not strictly correct, while we should enforce that packaging has a
type handler of the same id,
         // we don't
         try
         {
             installer.install( file, artifact, localRepository );
-            installChecksums( artifact );
+            installChecksums( artifact, metadataFiles );
         }
         catch ( ArtifactInstallationException e )
         {
@@ -271,7 +275,7 @@ public class InstallFileMojo
             try
             {
                 installer.install( sources, artifact, localRepository );
-                installChecksums( artifact );
+                installChecksums( artifact, metadataFiles );
             }
             catch ( ArtifactInstallationException e )
             {
@@ -285,13 +289,15 @@ public class InstallFileMojo
             try
             {
                 installer.install( javadoc, artifact, localRepository );
-                installChecksums( artifact );
+                installChecksums( artifact, metadataFiles );
             }
             catch ( ArtifactInstallationException e )
             {
                 throw new MojoExecutionException( "Error installing API docs " + javadoc
+ ": " + e.getMessage(), e );
             }
         }
+
+        installChecksums( metadataFiles );
     }
 
     /**

Modified: maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java?rev=1055234&r1=1055233&r2=1055234&view=diff
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java
(original)
+++ maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java
Tue Jan  4 22:57:08 2011
@@ -26,7 +26,9 @@ import org.apache.maven.plugin.MojoExecu
 import org.apache.maven.project.artifact.ProjectArtifactMetadata;
 
 import java.io.File;
+import java.util.Collection;
 import java.util.Iterator;
+import java.util.LinkedHashSet;
 import java.util.List;
 
 /**
@@ -84,10 +86,12 @@ public class InstallMojo
 
         try
         {
+            Collection metadataFiles = new LinkedHashSet();
+
             if ( isPomArtifact )
             {
                 installer.install( pomFile, artifact, localRepository );
-                installChecksums( artifact );
+                installChecksums( artifact, metadataFiles );
             }
             else
             {
@@ -101,7 +105,7 @@ public class InstallMojo
                 if ( file != null && file.isFile() )
                 {
                     installer.install( file, artifact, localRepository );
-                    installChecksums( artifact );
+                    installChecksums( artifact, metadataFiles );
                 }
                 else if ( !attachedArtifacts.isEmpty() )
                 {
@@ -117,7 +121,7 @@ public class InstallMojo
                     }
 
                     installer.install( pomFile, pomArtifact, localRepository );
-                    installChecksums( pomArtifact );
+                    installChecksums( pomArtifact, metadataFiles );
                 }
                 else
                 {
@@ -131,8 +135,10 @@ public class InstallMojo
                 Artifact attached = (Artifact) i.next();
 
                 installer.install( attached.getFile(), attached, localRepository );
-                installChecksums( attached );
+                installChecksums( attached, metadataFiles );
             }
+
+            installChecksums( metadataFiles );
         }
         catch ( ArtifactInstallationException e )
         {



Mime
View raw message