From b273dab333c2bfb7af2dfc72024d7c5857f08f6c Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Sat, 6 Jun 2009 11:35:57 +0000 Subject: [PATCH] o Fixed aggregation of remote repositories git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@782231 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/project/RepositoryModelResolver.java | 16 +++++++++++++++- .../maven/model/resolution/ModelResolver.java | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java b/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java index efbfd3793e..2d686a02f5 100644 --- a/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java +++ b/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java @@ -21,7 +21,9 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Iterator; import java.util.List; +import java.util.Map; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; @@ -88,7 +90,19 @@ public void addRepository( Repository repository ) try { ArtifactRepository repo = repositorySystem.buildArtifactRepository( repository ); - remoteRepositories.addAll( 0, repositorySystem.getMirrors( Arrays.asList( repo ) ) ); + + ArtifactRepository mirror = repositorySystem.getMirrors( Arrays.asList( repo ) ).get( 0 ); + + for ( Iterator it = remoteRepositories.iterator(); it.hasNext(); ) + { + ArtifactRepository remoteRepository = it.next(); + if ( mirror.getId().equals( remoteRepository.getId() ) ) + { + it.remove(); + } + } + + remoteRepositories.add( 0, mirror ); } catch ( org.apache.maven.artifact.InvalidRepositoryException e ) { diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/resolution/ModelResolver.java b/maven-model-builder/src/main/java/org/apache/maven/model/resolution/ModelResolver.java index 98e715878c..cce54632d8 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/resolution/ModelResolver.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/resolution/ModelResolver.java @@ -33,9 +33,25 @@ public interface ModelResolver { + /** + * Tries to resolve the POM for the specified coordinates. + * + * @param groupId The group identifier of the POM, must not be {@code null}. + * @param artifactId The artifact identifier of the POM, must not be {@code null}. + * @param version The version of the POM, must not be {@code null}. + * @return The source of the requested POM, never {@code null}. + * @throws UnresolvableModelException If the POM could not be resolved from any configured repository. + */ ModelSource resolveModel( String groupId, String artifactId, String version ) throws UnresolvableModelException; + /** + * Adds a repository to use for subsequent resolution requests. The order in which repositories are added matters. + * When multiple repositories with the same identifier are added, only the last repository being added will be used. + * + * @param repository The repository to add to the internal search chain, must not be {@code null}. + * @throws InvalidRepositoryException If the repository could not be added (e.g. due to invalid URL or layout). + */ void addRepository( Repository repository ) throws InvalidRepositoryException;