Skip to content

Commit

Permalink
Now, the list of known mirrors is not an Iterable but a Stream
Browse files Browse the repository at this point in the history
  • Loading branch information
kevloral committed Jan 21, 2024
1 parent 48c008c commit 87fbbee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
package org.eclipse.tycho.p2maven.repository;

import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;

import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
Expand Down Expand Up @@ -161,12 +161,7 @@ public void initialize() throws InitializationException {
}

@Override
public Iterable<MavenRepositoryLocation> getMirrors() {
List<MavenRepositoryLocation> result = new ArrayList<>();
for (Mirror mirror : mirrors) {
MavenRepositoryLocation location = new MavenRepositoryLocation(mirror.getId(), URI.create(mirror.getUrl()));
result.add(location);
}
return result;
public Stream<MavenRepositoryLocation> getMirrors() {
return mirrors.stream().map(m -> new MavenRepositoryLocation(m.getId(), URI.create(m.getUrl())));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
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;
Expand Down Expand Up @@ -120,9 +119,8 @@ private static boolean certainlyNoRemoteURL(URI location) {
@Override
public Stream<MavenRepositoryLocation> getKnownMavenRepositoryLocations() {
// 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));
return Stream.concat(knownMavenRepositoryIds.entrySet().stream()
.map(e -> new MavenRepositoryLocation(e.getValue(), e.getKey())), settings.getMirrors());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.eclipse.tycho;

import java.net.URI;
import java.util.stream.Stream;

/**
* Provides the mirror configuration and credentials from the Maven settings for loading remote p2
Expand Down Expand Up @@ -63,6 +64,6 @@ public String toString() {
/**
* Returns all configured mirror locations.
*/
Iterable<MavenRepositoryLocation> getMirrors();
Stream<MavenRepositoryLocation> getMirrors();

}

0 comments on commit 87fbbee

Please sign in to comment.