You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by bo...@werken.com on 2003/02/04 09:13:05 UTC

[maven-bug] Reopened: (MAVEN-246) Additional remote repositories being ignored

Message:

   The following issue has been reopened.

   Reopener: dion gillard
       Date: Tue, 4 Feb 2003 2:13 AM

More patches needed
---------------------------------------------------------------------
View the issue:

  http://jira.werken.com/secure/ViewIssue.jspa?key=MAVEN-246


Here is an overview of the issue:
---------------------------------------------------------------------
        Key: MAVEN-246
    Summary: Additional remote repositories being ignored
       Type: Bug

     Status: Assigned
   Priority: Major

 Time Spent: Unknown
   Estimate: 0 minutes

    Project: maven
  Component: core
   Versions:
             1.0-beta-8

   Assignee: Jason van Zyl
   Reporter: Darren Collins

    Created: Sun, 2 Feb 2003 3:22 PM
    Updated: Tue, 4 Feb 2003 2:13 AM

Description:
I'm using MAVEN HEAD from 2/1/03. I've overridden the remote repo property as the following 
maven.repo.remote=http://somerepo/maven,http://www.ibiblio.org/maven. The problem arises when Maven tries to retrieve a project dependency that is in one, but not both, of the remote repos. If an artifact doesn't exist in a remote repo, then a FileNotFoundException is thrown (it seems from HttpURLConnection.getResponseCode() in HttpUtils.java). The FileNotFoundException is caught in DependencyVerifier.getRemoteArtifact(Artifact) and returns false, which exits the loop. So additional remote repos are not checked or if the artifact was found in a previous remote repo in the list then returning false erronously reports the dependency as failed. I tested with the touchstone build by adding a test jar c.jar to the project dependencies, uploaded c.jar to http://somerepo/maven, and set maven.repo.remote=http://somerepo/maven,http://www.ibiblio.org/maven in project.properties. I ran maven:jar-install and the build failed due to the unsatisfied dependency. I then applied the patch below to DependencyVerifier and ran the same test and it worked correctly. 

Patch:

Index: DependencyVerifier.java
===================================================================
RCS file: /home/cvspublic/jakarta-turbine-maven/src/java/org/apache/maven/verifier/DependencyVerifier.java,v
retrieving revision 1.15
diff -u -r1.15 DependencyVerifier.java
--- DependencyVerifier.java	31 Jan 2003 17:15:05 -0000	1.15
+++ DependencyVerifier.java	2 Feb 2003 20:16:48 -0000
@@ -63,6 +63,7 @@
 import org.apache.maven.util.HttpUtils;
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -291,8 +292,10 @@
      */
     private boolean getRemoteArtifact( Artifact artifact )
     {
+        boolean artifactFound = false;
+
         for ( Iterator i = getProject().getContext().getMavenRepoRemote().iterator(); i.hasNext(); )
-        {
+        {            
             String remoteRepo = (String) i.next();
 
             // The username and password parameters are not being
@@ -315,6 +318,22 @@
                                    getProject().getContext().getProxyUserName(),
                                    getProject().getContext().getProxyPassword(),
                                    true );
+
+                // Artifact was found, continue checking additional remote repos (if any)
+                // in case there is a newer version (i.e. snapshots) in another repo  
+                artifactFound = true;                                   
+            }
+            catch ( FileNotFoundException e )
+            {
+                // If there are additional remote repos, then ignore exception
+                // as artifact may be found in another remote repo. If there
+                // are no more remote repos to check and the artifact wasn't found in 
+                // a previous remote repo, then return false indicating
+                // that the artifact could not be found in any of the remote repos
+                if ( !i.hasNext() && !artifactFound)
+                {
+                    return false;
+                }                
             }
             catch ( Exception e )
             {



---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://jira.werken.com/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira