You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jd...@apache.org on 2005/07/12 22:08:22 UTC

svn commit: r216013 - in /maven/components/trunk: maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/ maven-core-it/it0013/ maven-core-it/it0015/ maven-core-it/it0020/ maven-core-it/it0021/ maven-plugins/ maven-plugins/m...

Author: jdcasey
Date: Tue Jul 12 13:08:21 2005
New Revision: 216013

URL: http://svn.apache.org/viewcvs?rev=216013&view=rev
Log:
Fixing problem with using distributionManagement repository definition for download of plugins.xml metadata.

Now, in order to build a maven plugin, you need two things:

1. a repository defined in distributionManagment
2. a repository defined in <repositories/> which has the same id as the one in distributionManagement.

This is necessary, since in most cases SSH will be used in the distributionManagement definition for uploading the plugin...which means that the download of the existing plugins.xml file might not be available for users trying to run an install. SSH requires authentication information, and users (particularly those running the bootstrap) might not have this auth info.


Modified:
    maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java
    maven/components/trunk/maven-core-it/it0013/pom.xml
    maven/components/trunk/maven-core-it/it0015/pom.xml
    maven/components/trunk/maven-core-it/it0020/pom.xml
    maven/components/trunk/maven-core-it/it0021/pom.xml
    maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/ValidatePluginPomMojo.java
    maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/metadata/GenerateUpdatedMappingMojo.java
    maven/components/trunk/maven-plugins/pom.xml

Modified: maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java?rev=216013&r1=216012&r2=216013&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java (original)
+++ maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java Tue Jul 12 13:08:21 2005
@@ -6,12 +6,9 @@
 import org.apache.maven.wagon.TransferFailedException;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.IOUtil;
 
 import java.io.File;
-import java.io.FileReader;
 import java.io.IOException;
-import java.io.Reader;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -46,8 +43,6 @@
                 {
                     wagonManager.getRepositoryMetadata( metadata, remote, metadataFile );
 
-                    verifyLocalRepositoryFile( metadataFile );
-
                     metadata.setFile( metadataFile );
                 }
                 catch ( TransferFailedException e )
@@ -60,13 +55,6 @@
                     throw new RepositoryMetadataManagementException( metadata, "Remote repository metadata not found.",
                                                                      e );
                 }
-                catch ( IOException e )
-                {
-                    throw new RepositoryMetadataManagementException(
-                                                                     metadata,
-                                                                     "Download of repository metadata resulted in an invalid file.",
-                                                                     e );
-                }
             }
         }
     }
@@ -137,29 +125,6 @@
         realignedPath = "/REPOSITORY-INF/" + remoteId + realignedPath;
 
         return new File( local.getBasedir(), realignedPath );
-    }
-
-    private void verifyLocalRepositoryFile( File metadataFile )
-        throws IOException
-    {
-        Reader metadataReader = null;
-
-        try
-        {
-            metadataReader = new FileReader( metadataFile );
-
-            char[] cbuf = new char[16];
-
-            while ( metadataReader.read( cbuf ) > -1 )
-            {
-                // do nothing...just verify that it can be read.
-            }
-        }
-        finally
-        {
-            IOUtil.close( metadataReader );
-        }
-
     }
 
 }

Modified: maven/components/trunk/maven-core-it/it0013/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0013/pom.xml?rev=216013&r1=216012&r2=216013&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/it0013/pom.xml (original)
+++ maven/components/trunk/maven-core-it/it0013/pom.xml Tue Jul 12 13:08:21 2005
@@ -22,7 +22,7 @@
   </dependencies>
   <distributionManagement>
     <repository>
-      <id>test-repo</id>
+      <id>central</id>
       <name>Test Repository</name>
       <url>file:/tmp/testRepo</url>
     </repository>

Modified: maven/components/trunk/maven-core-it/it0015/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0015/pom.xml?rev=216013&r1=216012&r2=216013&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/it0015/pom.xml (original)
+++ maven/components/trunk/maven-core-it/it0015/pom.xml Tue Jul 12 13:08:21 2005
@@ -31,7 +31,7 @@
   </build>
   <distributionManagement>
     <repository>
-      <id>test-repo</id>
+      <id>central</id>
       <name>Test Repository</name>
       <url>file:/tmp/testRepo</url>
     </repository>

Modified: maven/components/trunk/maven-core-it/it0020/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0020/pom.xml?rev=216013&r1=216012&r2=216013&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/it0020/pom.xml (original)
+++ maven/components/trunk/maven-core-it/it0020/pom.xml Tue Jul 12 13:08:21 2005
@@ -23,7 +23,7 @@
   </build>
   <distributionManagement>
     <repository>
-      <id>test-repo</id>
+      <id>central</id>
       <name>Test Repository</name>
       <url>file:/tmp/testRepo</url>
     </repository>

Modified: maven/components/trunk/maven-core-it/it0021/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0021/pom.xml?rev=216013&r1=216012&r2=216013&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/it0021/pom.xml (original)
+++ maven/components/trunk/maven-core-it/it0021/pom.xml Tue Jul 12 13:08:21 2005
@@ -27,7 +27,7 @@
   
   <distributionManagement>
     <repository>
-      <id>test-repo</id>
+      <id>central</id>
       <name>Test Repository</name>
       <url>file:/tmp/testRepo</url>
     </repository>

Modified: maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/ValidatePluginPomMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/ValidatePluginPomMojo.java?rev=216013&r1=216012&r2=216013&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/ValidatePluginPomMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/ValidatePluginPomMojo.java Tue Jul 12 13:08:21 2005
@@ -5,6 +5,9 @@
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
 
+import java.util.Iterator;
+import java.util.List;
+
 /**
  * @phase validate
  * @goal validatePom
@@ -22,12 +25,41 @@
     public void execute()
         throws MojoExecutionException
     {
-            ArtifactRepository distributionRepository = project.getDistributionManagementArtifactRepository();
-            
-            if ( distributionRepository == null )
+        ArtifactRepository distributionRepository = project.getDistributionManagementArtifactRepository();
+
+        if ( distributionRepository == null )
+        {
+            throw new MojoExecutionException(
+                                              "You must provide a distributionManagement section with a repository element in your POM." );
+        }
+
+        String distributionRepositoryId = distributionRepository.getId();
+
+        List remoteArtifactRepositories = project.getRemoteArtifactRepositories();
+
+        ArtifactRepository remote = null;
+
+        for ( Iterator it = remoteArtifactRepositories.iterator(); it.hasNext(); )
+        {
+            ArtifactRepository remoteRepository = (ArtifactRepository) it.next();
+
+            if ( distributionRepositoryId.equals( remoteRepository.getId() ) )
             {
-                throw new MojoExecutionException( "You must provide a distributionManagement section with a repository element in your POM." );
+                remote = remoteRepository;
+                break;
             }
+        }
+
+        if ( remote == null )
+        {
+            StringBuffer message = new StringBuffer();
+            
+            message.append( "You must provide a artifact repository definition in <repositories/> that matches " +
+                    "the id of the repository specified in <distributionManagement/>: \'"
+                                                  + distributionRepositoryId + "\'." );
+            
+            throw new MojoExecutionException( message.toString() );
+        }
     }
 
 }

Modified: maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/metadata/GenerateUpdatedMappingMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/metadata/GenerateUpdatedMappingMojo.java?rev=216013&r1=216012&r2=216013&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/metadata/GenerateUpdatedMappingMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/metadata/GenerateUpdatedMappingMojo.java Tue Jul 12 13:08:21 2005
@@ -24,6 +24,7 @@
 import java.io.Reader;
 import java.io.Writer;
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * @phase package
@@ -70,6 +71,24 @@
     {
         ArtifactRepository distributionRepository = project.getDistributionManagementArtifactRepository();
         
+        String distributionRepositoryId = distributionRepository.getId();
+
+        List remoteArtifactRepositories = project.getRemoteArtifactRepositories();
+
+        ArtifactRepository readRemoteRepository = null;
+
+        for ( Iterator it = remoteArtifactRepositories.iterator(); it.hasNext(); )
+        {
+            ArtifactRepository currentRepository = (ArtifactRepository) it.next();
+
+            if ( distributionRepositoryId.equals( currentRepository.getId() ) )
+            {
+                readRemoteRepository = currentRepository;
+                
+                break;
+            }
+        }
+        
         PluginMappingXpp3Reader mappingReader = new PluginMappingXpp3Reader();
         
         PluginMap pluginMap = null;
@@ -78,7 +97,7 @@
         
         try
         {
-            repositoryMetadataManager.resolve( metadata, distributionRepository, localRepository );
+            repositoryMetadataManager.resolve( metadata, readRemoteRepository, localRepository );
             
             Reader reader = null;
             
@@ -109,15 +128,15 @@
             
             if ( cause != null && ( cause instanceof ResourceDoesNotExistException ) )
             {
-                getLog().info( "Cannot find " + metadata + " on remote repository. We'll create a new one." );
-                getLog().debug( "Metadata " + metadata + " not found.", e );
+                getLog().info( "Cannot find " + metadata + " on remote repository. Creating a new one." );
+                getLog().debug( "Metadata " + metadata + " cannot be resolved.", e );
                 
                 pluginMap = new PluginMap();
                 pluginMap.setGroupId( project.getGroupId() );
             }
             else
             {
-                throw new MojoExecutionException( "Cannot resolve plugin-mapping metadata: " + metadata, e );
+                throw new MojoExecutionException( "Failed to resolve " + metadata, e );
             }
         }
         

Modified: maven/components/trunk/maven-plugins/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/pom.xml?rev=216013&r1=216012&r2=216013&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/pom.xml (original)
+++ maven/components/trunk/maven-plugins/pom.xml Tue Jul 12 13:08:21 2005
@@ -71,7 +71,7 @@
   </organization>
   <distributionManagement>
     <repository>
-      <id>repo1</id>
+      <id>central</id>
       <name>Maven Central Repository</name>
       <url>scp://repo1.maven.org/home/projects/maven/repository-staging/to-ibiblio/maven2/plugins</url>
     </repository>



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