Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump maven-dependency-tree from 2.2 to 3.1.1 #305

Merged
merged 1 commit into from
Aug 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-dependency-tree</artifactId>
<version>2.2</version>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
Expand Down
34 changes: 17 additions & 17 deletions src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -89,6 +90,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
import java.util.Queue;
import java.util.Set;

/**
Expand Down Expand Up @@ -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;

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

/**
* The ArtifactFactory required to resolve POM using {@link #modelBuilder}.
* The ArtifactFactory required to resolve POM.
*/
// Neither ArtifactFactory nor DefaultArtifactFactory tells what to use instead
@Component
Expand Down Expand Up @@ -371,7 +373,7 @@ public class FlattenMojo
private DependencyResolver dependencyResolver;

@Component( hint = "default" )
private DependencyTreeBuilder dependencyTreeBuilder;
private DependencyGraphBuilder dependencyGraphBuilder;

@Component(role = ArtifactDescriptorReader.class)
private ArtifactDescriptorReader artifactDescriptorReader;
Expand Down Expand Up @@ -1080,19 +1082,21 @@ private void createFlattenedDependenciesDirect( List<Dependency> 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<Dependency> projectDependencies, List<Dependency> flattenedDependencies )
throws DependencyTreeBuilderException, ArtifactDescriptorException
throws ArtifactDescriptorException, DependencyGraphBuilderException
{
final Queue<DependencyNode> dependencyNodeLinkedList = new LinkedList<>();
final Set<String> 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()
{
Expand All @@ -1110,10 +1114,6 @@ private void createFlattenedDependenciesAll( List<Dependency> projectDependencie
return false;
}
}
if (node.getState() != DependencyNode.INCLUDED)
{
return false;
}
if (node.getArtifact().isOptional())
{
return false;
Expand Down