From 48c008cc6de65c7bec2f01a0f1cfb525d5b6d601 Mon Sep 17 00:00:00 2001 From: "Jose M. Arnesto" Date: Sun, 7 Jan 2024 23:28:58 +0100 Subject: [PATCH] Instead of storing the mirror ids, the new getMirrors method is used. --- .../DefaultRepositoryIdManager.java | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/repository/DefaultRepositoryIdManager.java b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/repository/DefaultRepositoryIdManager.java index 0884682242..cbd314aa9d 100644 --- a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/repository/DefaultRepositoryIdManager.java +++ b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/repository/DefaultRepositoryIdManager.java @@ -18,6 +18,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Stream; +import java.util.stream.StreamSupport; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; @@ -40,11 +41,6 @@ public class DefaultRepositoryIdManager implements IRepositoryIdManager { private Map knownMavenRepositoryIds = new ConcurrentHashMap<>(); - /** - * Map of known mirror identifiers, indexed by their URI. - */ - private Map knownMavenMirrorIds = new ConcurrentHashMap<>(); - @Override public void addMapping(String mavenRepositoryId, URI location) { if (mavenRepositoryId == null) @@ -57,15 +53,6 @@ public void addMapping(String mavenRepositoryId, URI location) { logger.warn("p2 repository with URL " + key + " is associated with multiple IDs; was '" + previousValue + "', now is '" + mavenRepositoryId + "'"); } - - // Checks if a mirror exists for the given location - MavenRepositoryLocation repositoryLocation = new MavenRepositoryLocation(mavenRepositoryId, key); - MavenRepositoryLocation mirrorLocation = settings.getMirror(repositoryLocation); - if (mirrorLocation != null) { - // A mirror exists. Adds its id to the map of known mirror ids. - URI mirrorKey = normalize(mirrorLocation.getURL()); - knownMavenMirrorIds.put(mirrorKey, mirrorLocation.getId()); - } } private static URI normalize(URI location) { @@ -132,9 +119,11 @@ private static boolean certainlyNoRemoteURL(URI location) { @Override public Stream getKnownMavenRepositoryLocations() { - return Stream.concat(knownMavenRepositoryIds.entrySet().stream(), knownMavenMirrorIds.entrySet().stream()) - .map(e -> new MavenRepositoryLocation(e.getValue(), e.getKey())); - } + // Returns both repository and mirror locations + return Stream.concat( + knownMavenRepositoryIds.entrySet().stream().map(e -> new MavenRepositoryLocation(e.getValue(), e.getKey())), + StreamSupport.stream(settings.getMirrors().spliterator(), false)); + } @Override public MavenRepositorySettings getSettings() {