From 579f6f798284aa3ccb990d8fec91e381043cbd42 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Tue, 9 Aug 2022 00:16:13 +0200 Subject: [PATCH] Bump maven-dependency-tree from 2.2 to 3.1.1 --- pom.xml | 2 +- .../codehaus/mojo/flatten/FlattenMojo.java | 34 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index 44501fcf..fb52bfb3 100644 --- a/pom.xml +++ b/pom.xml @@ -162,7 +162,7 @@ org.apache.maven.shared maven-dependency-tree - 2.2 + 3.1.1 org.codehaus.plexus diff --git a/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java b/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java index bf764dce..1218c47e 100644 --- a/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java +++ b/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java @@ -19,7 +19,6 @@ * under the License. */ -import java.util.Queue; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; @@ -51,11 +50,13 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.MavenProject; -import org.apache.maven.shared.dependency.tree.DependencyNode; -import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder; -import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; -import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor; +import org.apache.maven.project.ProjectBuildingRequest; +import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder; +import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException; +import org.apache.maven.shared.dependency.graph.DependencyNode; +import org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor; import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; import org.codehaus.mojo.flatten.cifriendly.CiInterpolator; import org.codehaus.mojo.flatten.model.resolution.FlattenModelResolver; @@ -89,6 +90,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Properties; +import java.util.Queue; import java.util.Set; /** @@ -224,7 +226,7 @@ public class FlattenMojo @Parameter( property = "updatePomFile" ) private Boolean updatePomFile; - /** The {@link ArtifactRepository} required to resolve POM using {@link #modelBuilder}. */ + /** The {@link ArtifactRepository} required to resolve POM. */ @Parameter( defaultValue = "${localRepository}", readonly = true, required = true ) private ArtifactRepository localRepository; @@ -284,7 +286,7 @@ public class FlattenMojo * * * bom - * Like {@link #ossrh} but additionally keeps {@link Model#getDependencyManagement() dependencyManagement} and + * Like ossrh but additionally keeps {@link Model#getDependencyManagement() dependencyManagement} and * {@link Model#getProperties() properties}. Especially it will keep the {@link Model#getDependencyManagement() * dependencyManagement} as-is without resolving parent influences and import-scoped dependencies. This is * useful if your POM represents a projectDependen * * @param projectDependencies is the effective POM {@link Model}'s current dependencies * @param flattenedDependencies is the {@link List} where to add the collected {@link Dependency dependencies}. - * @throws DependencyTreeBuilderException + * @throws DependencyGraphBuilderException * @throws ArtifactDescriptorException */ private void createFlattenedDependenciesAll( List projectDependencies, List flattenedDependencies ) - throws DependencyTreeBuilderException, ArtifactDescriptorException + throws ArtifactDescriptorException, DependencyGraphBuilderException { final Queue dependencyNodeLinkedList = new LinkedList<>(); final Set processedDependencies = new HashSet<>(); final Artifact projectArtifact = this.project.getArtifact(); - final DependencyNode dependencyNode = this.dependencyTreeBuilder.buildDependencyTree(this.project, - this.localRepository, null); + ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest( session.getProjectBuildingRequest() ); + buildingRequest.setProject( project ); + + final DependencyNode dependencyNode = this.dependencyGraphBuilder.buildDependencyGraph( buildingRequest, null); dependencyNode.accept(new DependencyNodeVisitor() { @@ -1110,10 +1114,6 @@ private void createFlattenedDependenciesAll( List projectDependencie return false; } } - if (node.getState() != DependencyNode.INCLUDED) - { - return false; - } if (node.getArtifact().isOptional()) { return false;