[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
This commit is contained in:
Tamas Cservenak 2023-12-18 13:00:26 +01:00 committed by GitHub
parent a1fdd89745
commit 8001c30b69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 11 deletions

View File

@ -48,9 +48,6 @@ import org.apache.maven.project.DependencyResolutionResult;
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<Node> 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<DependencyNode> dependencies = new ArrayList<>();
DependencyVisitor builder = new PreorderDependencyNodeConsumerVisitor(dependencies::add);
DependencyFilter filter = getScopeDependencyFilter(scope);
DependencyVisitor visitor = new FilteringDependencyVisitor(builder, filter);
root.accept(visitor);
List<DependencyNode> dependencies = session.getRepositorySystem()
.flattenDependencyNodes(session.getSession(), root, getScopeDependencyFilter(scope));
dependencies.remove(root);
return map(dependencies, session::getNode);
}