Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
aloubyansky committed Mar 25, 2024
1 parent 5f5eb78 commit 39e78ba
Showing 1 changed file with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.eclipse.aether.graph.DefaultDependencyNode;
import org.eclipse.aether.graph.Dependency;
import org.eclipse.aether.graph.DependencyNode;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.util.artifact.JavaScopes;
import org.eclipse.aether.util.graph.transformer.ConflictResolver;
import org.eclipse.aether.util.graph.visitor.DependencyGraphDumper;
Expand Down Expand Up @@ -333,7 +334,7 @@ private static MavenArtifactResolver getResolver() throws BootstrapMavenExceptio
.setRemoteRepositoryManager(resolver.getRemoteRepositoryManager())
.setRemoteRepositories(resolver.getRepositories())
.build();
return resolver;
return ensureRedhatEnabled(resolver);
}

private static MavenArtifactResolver getDefaultResolver() throws BootstrapMavenException {
Expand All @@ -349,7 +350,30 @@ private static MavenArtifactResolver getDefaultResolver() throws BootstrapMavenE
.setRemoteRepositoryManager(resolver.getRemoteRepositoryManager())
.setRemoteRepositories(resolver.getRepositories())
.build();
return resolver;
return ensureRedhatEnabled(resolver);
}

private static MavenArtifactResolver ensureRedhatEnabled(MavenArtifactResolver resolver) {
for(var r : resolver.getRepositories()) {
if(r.getUrl().contains("redhat")) {
return resolver;
}
}
var rhRepos = List.of(new RemoteRepository.Builder("redhat", "default", "https://maven.repository.redhat.com/ga/").build());
try {
var config = BootstrapMavenContext.config()
.setRepositorySystem(resolver.getSystem())
.setRepositorySystemSession(resolver.getSession())
.setRemoteRepositoryManager(resolver.getRemoteRepositoryManager())
.setRemoteRepositories(
resolver.getRemoteRepositoryManager().aggregateRepositories(
resolver.getSession(), rhRepos, resolver.getRepositories(), false))
.setRemotePluginRepositories(resolver.getRemoteRepositoryManager().aggregateRepositories(
resolver.getSession(), rhRepos, resolver.context.getRemotePluginRepositories(), false));
return new MavenArtifactResolver(new BootstrapMavenContext(config));
} catch (BootstrapMavenException e) {
throw new RuntimeException(e);
}
}

public static class DependencyLevel {
Expand Down Expand Up @@ -416,7 +440,7 @@ public static DependencyNode visit(DependencyNode node, DependencyNodeVisitor vi
log("Parent " + visit.rewiredParent.getDependency());
DependencyNode prevNode = null;
for (var n : entry.getKey().getChildren()) {
log(" " + n.getDependency());
log(" " + n.getDependency() + " " + n.getVersionConstraint().getVersion() + " " + n.getVersionConstraint().getRange());
if (prevNode == null
|| prevNode.getArtifact().getArtifactId().equals(n.getArtifact().getArtifactId())
&& prevNode.getArtifact().getGroupId().equals(n.getArtifact().getGroupId())
Expand Down

0 comments on commit 39e78ba

Please sign in to comment.