maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r674941 - in /maven/artifact/trunk/src: main/java/org/apache/maven/artifact/manager/ main/java/org/apache/maven/artifact/repository/ test/java/org/apache/maven/artifact/manager/
Date Tue, 08 Jul 2008 20:36:15 GMT
Author: jvanzyl
Date: Tue Jul  8 13:36:14 2008
New Revision: 674941

URL: http://svn.apache.org/viewvc?rev=674941&view=rev
Log:
MARTIFACT-29: Prevent checking from all remote repositories once the artifact is found.
Submitted by: Igor Fedorenko

Modified:
    maven/artifact/trunk/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
    maven/artifact/trunk/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java
    maven/artifact/trunk/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java

Modified: maven/artifact/trunk/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java?rev=674941&r1=674940&r2=674941&view=diff
==============================================================================
--- maven/artifact/trunk/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
(original)
+++ maven/artifact/trunk/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
Tue Jul  8 13:36:14 2008
@@ -333,14 +333,15 @@
                              boolean force )
         throws TransferFailedException, ResourceDoesNotExistException
     {
-        boolean successful = false;
-
         for (ArtifactRepository repository : remoteRepositories) {
             try
             {
                 getArtifact( artifact, repository, force );
 
-                successful = artifact.isResolved();
+                if (artifact.isResolved())
+                {
+                	break;
+                }
             }
             catch ( ResourceDoesNotExistException e )
             {
@@ -358,7 +359,7 @@
         }
 
         // if it already exists locally we were just trying to force it - ignore the update
-        if ( !successful && !artifact.getFile().exists() )
+        if ( !artifact.getFile().exists() )
         {
             throw new ResourceDoesNotExistException( "Unable to download the artifact from
any repository" );
         }

Modified: maven/artifact/trunk/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java?rev=674941&r1=674940&r2=674941&view=diff
==============================================================================
--- maven/artifact/trunk/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java
(original)
+++ maven/artifact/trunk/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java
Tue Jul  8 13:36:14 2008
@@ -35,7 +35,7 @@
     extends Repository
     implements ArtifactRepository
 {
-    private final ArtifactRepositoryLayout layout;
+    private ArtifactRepositoryLayout layout;
 
     private ArtifactRepositoryPolicy snapshots;
 

Modified: maven/artifact/trunk/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java
URL: http://svn.apache.org/viewvc/maven/artifact/trunk/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java?rev=674941&r1=674940&r2=674941&view=diff
==============================================================================
--- maven/artifact/trunk/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java
(original)
+++ maven/artifact/trunk/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java
Tue Jul  8 13:36:14 2008
@@ -21,6 +21,8 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.DefaultArtifact;
@@ -31,13 +33,16 @@
 import org.apache.maven.artifact.repository.DefaultArtifactRepository;
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
+import org.apache.maven.artifact.resolver.TestTransferListener;
 import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.wagon.ResourceDoesNotExistException;
 import org.apache.maven.wagon.TransferFailedException;
 import org.apache.maven.wagon.UnsupportedProtocolException;
 import org.apache.maven.wagon.Wagon;
 import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.TransferEvent;
 import org.apache.maven.wagon.events.TransferListener;
+import org.apache.maven.wagon.observers.AbstractTransferListener;
 import org.apache.maven.wagon.observers.Debug;
 import org.apache.maven.wagon.repository.Repository;
 import org.codehaus.plexus.PlexusTestCase;
@@ -68,6 +73,32 @@
         
         artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
     }
+    
+    public void testUnnecessaryRepositoryLookup() throws Exception {
+        Artifact artifact = createTestPomArtifact( "target/test-data/get-missing-pom" );
+
+        List<ArtifactRepository> repos = new ArrayList<ArtifactRepository>();
+        repos.add(new DefaultArtifactRepository( "repo1", "noop://url1", new ArtifactRepositoryLayoutStub()
));
+        repos.add(new DefaultArtifactRepository( "repo2", "noop://url2", new ArtifactRepositoryLayoutStub()
));
+
+        StringWagon wagon = (StringWagon) wagonManager.getWagon( "noop" );
+        wagon.addExpectedContent( repos.get(0).getLayout().pathOf( artifact ), "expected"
);
+        wagon.addExpectedContent( repos.get(1).getLayout().pathOf( artifact ), "expected"
);
+        
+        class TransferListener extends AbstractTransferListener {
+        	public List<TransferEvent> events = new ArrayList<TransferEvent>();
+        	@Override
+        	public void transferInitiated(TransferEvent transferEvent) {
+        		events.add(transferEvent);
+        	}
+        };
+        TransferListener listener = new TransferListener();
+
+        wagonManager.setDownloadMonitor(listener);
+        wagonManager.getArtifact( artifact, repos, false );
+
+        assertEquals(1, listener.events.size());
+    }
 
     public void testGetMissingPomUncached() throws TransferFailedException, UnsupportedProtocolException,
IOException
     {



Mime
View raw message