From 8001c30b6949b16857f15bc8e30914ae5108c61c Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Mon, 18 Dec 2023 13:00:26 +0100 Subject: [PATCH] [MNG-7974] Upgrade to Resolver 2.0.0-alpha-5 Addendum (#1348) There was a TODO in code that I missed. --- https://issues.apache.org/jira/browse/MNG-7974 --- .../internal/impl/DefaultDependencyResolver.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultDependencyResolver.java b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultDependencyResolver.java index 957f3d5cd2e4..56f3c5bd5315 100644 --- a/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultDependencyResolver.java +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultDependencyResolver.java @@ -48,9 +48,6 @@ import org.apache.maven.project.MavenProject; import org.eclipse.aether.graph.DependencyFilter; import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.graph.DependencyVisitor; -import org.eclipse.aether.util.graph.visitor.FilteringDependencyVisitor; -import org.eclipse.aether.util.graph.visitor.PreorderDependencyNodeConsumerVisitor; import static org.apache.maven.internal.impl.Utils.cast; import static org.apache.maven.internal.impl.Utils.map; @@ -63,16 +60,10 @@ public class DefaultDependencyResolver implements DependencyResolver { @Override public List flatten(Session s, Node node, ResolutionScope scope) throws DependencyResolverException { InternalSession session = InternalSession.from(s); - - // TODO: v4: refactor with RepositorySystem#flattenDependencyNodes with resolver alpha-3 DependencyNode root = cast(AbstractNode.class, node, "node").getDependencyNode(); - List dependencies = new ArrayList<>(); - DependencyVisitor builder = new PreorderDependencyNodeConsumerVisitor(dependencies::add); - DependencyFilter filter = getScopeDependencyFilter(scope); - DependencyVisitor visitor = new FilteringDependencyVisitor(builder, filter); - root.accept(visitor); + List dependencies = session.getRepositorySystem() + .flattenDependencyNodes(session.getSession(), root, getScopeDependencyFilter(scope)); dependencies.remove(root); - return map(dependencies, session::getNode); }