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 2009/01/04 18:19:39 UTC

svn commit: r731298 - in /maven/plugins/trunk/maven-install-plugin/src: it/attach-jar-checksum/ it/pom-checksum/ it/pom-checksum/src/ it/pom-checksum/src/site/ main/java/org/apache/maven/plugin/install/

Author: bentmann
Date: Sun Jan  4 09:19:37 2009
New Revision: 731298

URL: http://svn.apache.org/viewvc?rev=731298&view=rev
Log:
[MINSTALL-56] No checksums installed for project with packaging POM

o Added checksums for site descriptors (and any other metadata attached to artifacts)

Added:
    maven/plugins/trunk/maven-install-plugin/src/it/pom-checksum/src/
    maven/plugins/trunk/maven-install-plugin/src/it/pom-checksum/src/site/
    maven/plugins/trunk/maven-install-plugin/src/it/pom-checksum/src/site/site.xml   (with props)
Modified:
    maven/plugins/trunk/maven-install-plugin/src/it/attach-jar-checksum/verify.bsh
    maven/plugins/trunk/maven-install-plugin/src/it/pom-checksum/verify.bsh
    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/it/attach-jar-checksum/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/attach-jar-checksum/verify.bsh?rev=731298&r1=731297&r2=731298&view=diff
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/attach-jar-checksum/verify.bsh (original)
+++ maven/plugins/trunk/maven-install-plugin/src/it/attach-jar-checksum/verify.bsh Sun Jan  4 09:19:37 2009
@@ -5,7 +5,6 @@
 
 String[] paths =
 {
-    "org/apache/maven/its/install/ajc/test/maven-metadata-local.xml",
     "org/apache/maven/its/install/ajc/test/1.0-SNAPSHOT/test-1.0-SNAPSHOT.pom",
     "org/apache/maven/its/install/ajc/test/1.0-SNAPSHOT/test-1.0-SNAPSHOT.pom.md5",
     "org/apache/maven/its/install/ajc/test/1.0-SNAPSHOT/test-1.0-SNAPSHOT.pom.sha1",
@@ -15,6 +14,12 @@
     "org/apache/maven/its/install/ajc/test/1.0-SNAPSHOT/test-1.0-SNAPSHOT-sources.jar",
     "org/apache/maven/its/install/ajc/test/1.0-SNAPSHOT/test-1.0-SNAPSHOT-sources.jar.md5",
     "org/apache/maven/its/install/ajc/test/1.0-SNAPSHOT/test-1.0-SNAPSHOT-sources.jar.sha1",
+    "org/apache/maven/its/install/ajc/test/1.0-SNAPSHOT/maven-metadata-local.xml",
+    "org/apache/maven/its/install/ajc/test/1.0-SNAPSHOT/maven-metadata-local.xml.md5",
+    "org/apache/maven/its/install/ajc/test/1.0-SNAPSHOT/maven-metadata-local.xml.sha1",
+    "org/apache/maven/its/install/ajc/test/maven-metadata-local.xml",
+    "org/apache/maven/its/install/ajc/test/maven-metadata-local.xml.md5",
+    "org/apache/maven/its/install/ajc/test/maven-metadata-local.xml.sha1",
 };
 
 for ( String path : paths )

Added: maven/plugins/trunk/maven-install-plugin/src/it/pom-checksum/src/site/site.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/pom-checksum/src/site/site.xml?rev=731298&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/pom-checksum/src/site/site.xml (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/pom-checksum/src/site/site.xml Sun Jan  4 09:19:37 2009
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+
+<project>
+</project>

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/pom-checksum/src/site/site.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-install-plugin/src/it/pom-checksum/src/site/site.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/plugins/trunk/maven-install-plugin/src/it/pom-checksum/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/pom-checksum/verify.bsh?rev=731298&r1=731297&r2=731298&view=diff
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/pom-checksum/verify.bsh (original)
+++ maven/plugins/trunk/maven-install-plugin/src/it/pom-checksum/verify.bsh Sun Jan  4 09:19:37 2009
@@ -5,11 +5,18 @@
 
 String[] paths =
 {
-    "org/apache/maven/its/install/pc/test/maven-metadata-local.xml",
-    "org/apache/maven/its/install/pc/test/1.0-SNAPSHOT/maven-metadata-local.xml",
     "org/apache/maven/its/install/pc/test/1.0-SNAPSHOT/test-1.0-SNAPSHOT.pom",
     "org/apache/maven/its/install/pc/test/1.0-SNAPSHOT/test-1.0-SNAPSHOT.pom.md5",
     "org/apache/maven/its/install/pc/test/1.0-SNAPSHOT/test-1.0-SNAPSHOT.pom.sha1",
+    "org/apache/maven/its/install/pc/test/1.0-SNAPSHOT/test-1.0-SNAPSHOT-site.xml",
+    "org/apache/maven/its/install/pc/test/1.0-SNAPSHOT/test-1.0-SNAPSHOT-site.xml.md5",
+    "org/apache/maven/its/install/pc/test/1.0-SNAPSHOT/test-1.0-SNAPSHOT-site.xml.sha1",
+    "org/apache/maven/its/install/pc/test/1.0-SNAPSHOT/maven-metadata-local.xml",
+    "org/apache/maven/its/install/pc/test/1.0-SNAPSHOT/maven-metadata-local.xml.md5",
+    "org/apache/maven/its/install/pc/test/1.0-SNAPSHOT/maven-metadata-local.xml.sha1",
+    "org/apache/maven/its/install/pc/test/maven-metadata-local.xml",
+    "org/apache/maven/its/install/pc/test/maven-metadata-local.xml.md5",
+    "org/apache/maven/its/install/pc/test/maven-metadata-local.xml.sha1",
 };
 
 for ( String path : paths )

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=731298&r1=731297&r2=731298&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 Sun Jan  4 09:19:37 2009
@@ -32,6 +32,8 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Collection;
+import java.util.Iterator;
 
 /**
  * Common fields for installation mojos.
@@ -108,21 +110,54 @@
     }
 
     /**
-     * Installs the checksums for the specified file if this has been enabled in the plugin configuration.
+     * 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.
      * 
-     * @param originalFile The path to the file from which the checksums are generated, must not be <code>null</code>.
-     * @param installedFile The base path from which the paths to the checksum files are derived, must not be
-     *            <code>null</code>.
+     * @param artifact The artifact for which to create checksums, must not be <code>null</code>.
+     * @throws MojoExecutionException If the checksums could not be installed.
+     */
+    protected void installChecksums( Artifact artifact )
+        throws MojoExecutionException
+    {
+        if ( !createChecksum )
+        {
+            return;
+        }
+
+        File artifactFile = getLocalRepoFile( artifact );
+        installChecksums( artifactFile );
+
+        Collection metadatas = artifact.getMetadataList();
+        if ( metadatas != null )
+        {
+            for ( Iterator it = metadatas.iterator(); it.hasNext(); )
+            {
+                ArtifactMetadata metadata = (ArtifactMetadata) it.next();
+                File metadataFile = getLocalRepoFile( metadata );
+                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,
+     *            must not be <code>null</code>.
      * @throws MojoExecutionException If the checksums could not be installed.
      */
-    protected void installChecksums( File originalFile, File installedFile )
+    private void installChecksums( File installedFile )
         throws MojoExecutionException
     {
         boolean signatureFile = installedFile.getName().endsWith( ".asc" );
-        if ( createChecksum && !signatureFile )
+        if ( installedFile.isFile() && !signatureFile )
         {
-            installChecksum( originalFile, installedFile, md5Digester, ".md5" );
-            installChecksum( originalFile, installedFile, sha1Digester, ".sha1" );
+            installChecksum( installedFile, installedFile, md5Digester, ".md5" );
+            installChecksum( installedFile, installedFile, sha1Digester, ".sha1" );
         }
     }
 

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=731298&r1=731297&r2=731298&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 Sun Jan  4 09:19:37 2009
@@ -248,7 +248,8 @@
         }
 
         // TODO: validate
-        // TODO: maybe not strictly correct, while we should enfore that packaging has a type handler of the same id, we don't
+        // TODO: maybe not strictly correct, while we should enforce that packaging has a type handler of the same id,
+        // we don't
         try
         {
             String localPath = localRepository.pathOf( artifact );
@@ -258,16 +259,12 @@
             if ( !file.equals( destination ) )
             {
                 installer.install( file, artifact, localRepository );
-                installChecksums( file, getLocalRepoFile( artifact ) );
-                if ( generatePom )
-                {
-                    installChecksums( generatedPomFile, getLocalRepoFile( metadata ) );
-                }
+                installChecksums( artifact );
 
                 if ( pomFile != null && pomFile.isFile() )
                 {
                     installer.install( pomFile, pomArtifact, localRepository );
-                    installChecksums( pomFile, getLocalRepoFile( pomArtifact ) );
+                    installChecksums( pomArtifact );
                 }
             }
             else

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=731298&r1=731297&r2=731298&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 Sun Jan  4 09:19:37 2009
@@ -93,7 +93,7 @@
             if ( isPomArtifact )
             {
                 installer.install( pomFile, artifact, localRepository );
-                installChecksums( pomFile, getLocalRepoFile( artifact ) );
+                installChecksums( artifact );
             }
             else
             {
@@ -107,8 +107,7 @@
                 if ( file != null && file.isFile() )
                 {
                     installer.install( file, artifact, localRepository );
-                    installChecksums( file, getLocalRepoFile( artifact ) );
-                    installChecksums( pomFile, getLocalRepoFile( metadata ) );
+                    installChecksums( artifact );
                 }
                 else if ( !attachedArtifacts.isEmpty() )
                 {
@@ -124,7 +123,7 @@
                     }
 
                     installer.install( pomFile, pomArtifact, localRepository );
-                    installChecksums( pomFile, getLocalRepoFile( pomArtifact ) );
+                    installChecksums( pomArtifact );
                 }
                 else
                 {
@@ -138,7 +137,7 @@
                 Artifact attached = (Artifact) i.next();
 
                 installer.install( attached.getFile(), attached, localRepository );
-                installChecksums( attached.getFile(), getLocalRepoFile( attached ) );
+                installChecksums( attached );
             }
         }
         catch ( ArtifactInstallationException e )