Index: pom.xml =================================================================== --- pom.xml (revision 615545) +++ pom.xml (working copy) @@ -266,27 +266,27 @@ org.apache.maven.wagon wagon-provider-api - 1.0-beta-2 + 1.0-rc1-SNAPSHOT org.apache.maven.wagon wagon-ssh - 1.0-beta-2 + 1.0-rc1-SNAPSHOT org.apache.maven.wagon wagon-ssh-external - 1.0-beta-2 + 1.0-rc1-SNAPSHOT org.apache.maven.wagon wagon-file - 1.0-beta-2 + 1.0-rc1-SNAPSHOT org.apache.maven.wagon - wagon-http-lightweight - 1.0-beta-2 + wagon-http + 1.0-rc1-SNAPSHOT easymock Index: maven-core/src/main/java/org/apache/maven/MavenArtifactFilterManager.java =================================================================== --- maven-core/src/main/java/org/apache/maven/MavenArtifactFilterManager.java (revision 615545) +++ maven-core/src/main/java/org/apache/maven/MavenArtifactFilterManager.java (working copy) @@ -65,8 +65,11 @@ artifacts.add( "wagon-provider-api" ); artifacts.add( "wagon-file" ); artifacts.add( "wagon-http-lightweight" ); + artifacts.add( "wagon-http" ); artifacts.add( "wagon-ssh" ); artifacts.add( "wagon-ssh-external" ); + artifacts.add( "commons-httpclient" ); + artifacts.add( "backport-util-concurrent" ); return new ExclusionSetFilter( artifacts ); } Index: maven-core/pom.xml =================================================================== --- maven-core/pom.xml (revision 615545) +++ maven-core/pom.xml (working copy) @@ -151,7 +151,7 @@ org.apache.maven.wagon - wagon-http-lightweight + wagon-http runtime Index: maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java =================================================================== --- maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java (revision 615545) +++ maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java (working copy) @@ -39,14 +39,13 @@ import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; +import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor; +import edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue; +import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit; +import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch; + public class DefaultArtifactResolver extends AbstractLogEnabled implements ArtifactResolver @@ -62,7 +61,14 @@ protected ArtifactFactory artifactFactory; private ArtifactCollector artifactCollector; + private final ThreadPoolExecutor resolveArtifactPool; + public DefaultArtifactResolver() + { + super(); + resolveArtifactPool = new ThreadPoolExecutor(3, 5, 3, TimeUnit.SECONDS, new LinkedBlockingQueue()); + } + // ---------------------------------------------------------------------- // Implementation // ---------------------------------------------------------------------- @@ -298,23 +304,37 @@ localRepository, remoteRepositories, source, filter, listeners ); - List resolvedArtifacts = new ArrayList(); - List missingArtifacts = new ArrayList(); + List resolvedArtifacts = Collections.synchronizedList(new ArrayList()); + List missingArtifacts = Collections.synchronizedList(new ArrayList()); + CountDownLatch latch = new CountDownLatch(artifactResolutionResult.getArtifactResolutionNodes().size()); + Map nodesByGroupId = new HashMap(); for ( Iterator i = artifactResolutionResult.getArtifactResolutionNodes().iterator(); i.hasNext(); ) { ResolutionNode node = (ResolutionNode) i.next(); - try + List nodes = (List) nodesByGroupId.get(node.getArtifact().getGroupId()); + if (nodes == null) { - resolve( node.getArtifact(), node.getRemoteRepositories(), localRepository ); - resolvedArtifacts.add( node.getArtifact() ); + nodes = new ArrayList(); + nodesByGroupId.put(node.getArtifact().getGroupId(), nodes); } - catch ( ArtifactNotFoundException anfe ) + nodes.add(node); + } + + try { + for (Iterator i = nodesByGroupId.values().iterator(); i.hasNext(); ) { - getLogger().debug( anfe.getMessage(), anfe ); - - missingArtifacts.add( node.getArtifact() ); + List nodes = (List) i.next(); + resolveArtifactPool.execute(new ResolveArtifactTask(resolveArtifactPool, latch, nodes, localRepository, resolvedArtifacts, missingArtifacts)); } - } + latch.await(); + } catch (InterruptedException e) { + throw new ArtifactResolutionException("Resolution interrupted", null, e); + } catch (RuntimeException ex) { + if (ex.getCause() instanceof ArtifactResolutionException) + throw (ArtifactResolutionException) ex.getCause(); + else + throw ex; + } if ( missingArtifacts.size() > 0 ) { @@ -342,4 +362,51 @@ remoteRepositories, source, null, listeners ); } + private class ResolveArtifactTask implements Runnable { + private List nodes; + private ArtifactRepository localRepository; + private List resolvedArtifacts; + private List missingArtifacts; + private CountDownLatch latch; + private ThreadPoolExecutor pool; + + public ResolveArtifactTask(ThreadPoolExecutor pool, CountDownLatch latch, List nodes, ArtifactRepository localRepository, List resolvedArtifacts, List missingArtifacts) { + this.nodes = nodes; + this.localRepository = localRepository; + this.resolvedArtifacts = resolvedArtifacts; + this.missingArtifacts = missingArtifacts; + this.latch = latch; + this.pool = pool; + } + + public void run() { + //getLogger().info("Size of nodes: "+nodes.size()+" on thread: "+Thread.currentThread().getId()); + Iterator i = nodes.iterator(); + ResolutionNode node = (ResolutionNode) i.next(); + i.remove(); + try { + resolveArtifact(node); + if (i.hasNext()) + pool.execute(new ResolveArtifactTask(pool, latch, nodes, localRepository, resolvedArtifacts, missingArtifacts)); + } catch (ArtifactResolutionException e) { + throw new RuntimeException(e); + } + latch.countDown(); + } + + private void resolveArtifact(ResolutionNode node) throws ArtifactResolutionException { + try + { + resolve( node.getArtifact(), node.getRemoteRepositories(), localRepository ); + resolvedArtifacts.add( node.getArtifact() ); + } + catch ( ArtifactNotFoundException anfe ) + { + getLogger().debug( anfe.getMessage(), anfe ); + + missingArtifacts.add( node.getArtifact() ); + } + } + } + } Index: maven-artifact-manager/pom.xml =================================================================== --- maven-artifact-manager/pom.xml (revision 615545) +++ maven-artifact-manager/pom.xml (working copy) @@ -55,6 +55,11 @@ wagon-provider-api + backport-util-concurrent + backport-util-concurrent + 3.1 + + easymock easymock 1.2_Java1.3