Skip to content

Commit 13c9a58

Browse files
Bump maven-dependency-tree from 2.2 to 3.1.1
1 parent bd94696 commit 13c9a58

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
<dependency>
163163
<groupId>org.apache.maven.shared</groupId>
164164
<artifactId>maven-dependency-tree</artifactId>
165-
<version>2.2</version>
165+
<version>3.1.1</version>
166166
</dependency>
167167
<dependency>
168168
<groupId>org.codehaus.plexus</groupId>

src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
* under the License.
2020
*/
2121

22-
import java.util.Queue;
2322
import org.apache.maven.artifact.Artifact;
2423
import org.apache.maven.artifact.factory.ArtifactFactory;
2524
import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -51,11 +50,13 @@
5150
import org.apache.maven.plugins.annotations.Mojo;
5251
import org.apache.maven.plugins.annotations.Parameter;
5352
import org.apache.maven.plugins.annotations.ResolutionScope;
53+
import org.apache.maven.project.DefaultProjectBuildingRequest;
5454
import org.apache.maven.project.MavenProject;
55-
import org.apache.maven.shared.dependency.tree.DependencyNode;
56-
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
57-
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
58-
import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor;
55+
import org.apache.maven.project.ProjectBuildingRequest;
56+
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder;
57+
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException;
58+
import org.apache.maven.shared.dependency.graph.DependencyNode;
59+
import org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor;
5960
import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver;
6061
import org.codehaus.mojo.flatten.cifriendly.CiInterpolator;
6162
import org.codehaus.mojo.flatten.model.resolution.FlattenModelResolver;
@@ -89,6 +90,7 @@
8990
import java.util.LinkedList;
9091
import java.util.List;
9192
import java.util.Properties;
93+
import java.util.Queue;
9294
import java.util.Set;
9395

9496
/**
@@ -224,7 +226,7 @@ public class FlattenMojo
224226
@Parameter( property = "updatePomFile" )
225227
private Boolean updatePomFile;
226228

227-
/** The {@link ArtifactRepository} required to resolve POM using {@link #modelBuilder}. */
229+
/** The {@link ArtifactRepository} required to resolve POM. */
228230
@Parameter( defaultValue = "${localRepository}", readonly = true, required = true )
229231
private ArtifactRepository localRepository;
230232

@@ -284,7 +286,7 @@ public class FlattenMojo
284286
* </tr>
285287
* <tr>
286288
* <td>bom</td>
287-
* <td>Like {@link #ossrh} but additionally keeps {@link Model#getDependencyManagement() dependencyManagement} and
289+
* <td>Like <code>ossrh</code> but additionally keeps {@link Model#getDependencyManagement() dependencyManagement} and
288290
* {@link Model#getProperties() properties}. Especially it will keep the {@link Model#getDependencyManagement()
289291
* dependencyManagement} <em>as-is</em> without resolving parent influences and import-scoped dependencies. This is
290292
* useful if your POM represents a <a href=
@@ -343,7 +345,7 @@ public class FlattenMojo
343345
private FlattenDependencyMode flattenDependencyMode;
344346

345347
/**
346-
* The ArtifactFactory required to resolve POM using {@link #modelBuilder}.
348+
* The ArtifactFactory required to resolve POM.
347349
*/
348350
// Neither ArtifactFactory nor DefaultArtifactFactory tells what to use instead
349351
@Component
@@ -371,7 +373,7 @@ public class FlattenMojo
371373
private DependencyResolver dependencyResolver;
372374

373375
@Component( hint = "default" )
374-
private DependencyTreeBuilder dependencyTreeBuilder;
376+
private DependencyGraphBuilder dependencyGraphBuilder;
375377

376378
@Component(role = ArtifactDescriptorReader.class)
377379
private ArtifactDescriptorReader artifactDescriptorReader;
@@ -1080,19 +1082,21 @@ private void createFlattenedDependenciesDirect( List<Dependency> projectDependen
10801082
*
10811083
* @param projectDependencies is the effective POM {@link Model}'s current dependencies
10821084
* @param flattenedDependencies is the {@link List} where to add the collected {@link Dependency dependencies}.
1083-
* @throws DependencyTreeBuilderException
1085+
* @throws DependencyGraphBuilderException
10841086
* @throws ArtifactDescriptorException
10851087
*/
10861088
private void createFlattenedDependenciesAll( List<Dependency> projectDependencies, List<Dependency> flattenedDependencies )
1087-
throws DependencyTreeBuilderException, ArtifactDescriptorException
1089+
throws ArtifactDescriptorException, DependencyGraphBuilderException
10881090
{
10891091
final Queue<DependencyNode> dependencyNodeLinkedList = new LinkedList<>();
10901092
final Set<String> processedDependencies = new HashSet<>();
10911093

10921094
final Artifact projectArtifact = this.project.getArtifact();
10931095

1094-
final DependencyNode dependencyNode = this.dependencyTreeBuilder.buildDependencyTree(this.project,
1095-
this.localRepository, null);
1096+
ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest( session.getProjectBuildingRequest() );
1097+
buildingRequest.setProject( project );
1098+
1099+
final DependencyNode dependencyNode = this.dependencyGraphBuilder.buildDependencyGraph( buildingRequest, null);
10961100

10971101
dependencyNode.accept(new DependencyNodeVisitor()
10981102
{
@@ -1110,10 +1114,6 @@ private void createFlattenedDependenciesAll( List<Dependency> projectDependencie
11101114
return false;
11111115
}
11121116
}
1113-
if (node.getState() != DependencyNode.INCLUDED)
1114-
{
1115-
return false;
1116-
}
11171117
if (node.getArtifact().isOptional())
11181118
{
11191119
return false;

0 commit comments

Comments
 (0)