Skip to content

Commit

Permalink
Drop other deprecated dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
cstamas committed May 27, 2024
1 parent 8bdc116 commit 741d7a2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 30 deletions.
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,6 @@
<artifactId>jdom2</artifactId>
<version>2.0.6.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-dependency-tree</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
Expand Down
42 changes: 17 additions & 25 deletions src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.project.ProjectBuildingResult;
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.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.WriterFactory;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.collection.CollectRequest;
import org.eclipse.aether.collection.CollectResult;
import org.eclipse.aether.collection.DependencyCollectionException;
import org.eclipse.aether.graph.DependencyNode;
import org.eclipse.aether.resolution.ArtifactRequest;
import org.eclipse.aether.resolution.ArtifactResolutionException;
import org.eclipse.aether.resolution.ArtifactResult;
Expand Down Expand Up @@ -400,12 +401,6 @@ public class ShadeMojo extends AbstractMojo {
@Inject
private RepositorySystem repositorySystem;

/**
* The dependency graph builder to use.
*/
@Inject
private DependencyGraphBuilder dependencyGraphBuilder;

/**
* ProjectBuilder, needed to create projects from the artifacts.
*/
Expand Down Expand Up @@ -985,7 +980,7 @@ private File shadedTestArtifactFile() {
// We need to find the direct dependencies that have been included in the uber JAR so that we can modify the
// POM accordingly.
private void createDependencyReducedPom(Set<String> artifactsToRemove)
throws IOException, DependencyGraphBuilderException, ProjectBuildingException {
throws IOException, ProjectBuildingException, DependencyCollectionException {
List<Dependency> transitiveDeps = new ArrayList<>();

// NOTE: By using the getArtifacts() we get the completely evaluated artifacts
Expand Down Expand Up @@ -1053,7 +1048,7 @@ private void createDependencyReducedPom(Set<String> artifactsToRemove)

private void rewriteDependencyReducedPomIfWeHaveReduction(
List<Dependency> dependencies, boolean modified, List<Dependency> transitiveDeps, Model model)
throws IOException, ProjectBuildingException, DependencyGraphBuilderException {
throws IOException, ProjectBuildingException, DependencyCollectionException {
if (modified) {
for (int loopCounter = 0; modified; loopCounter++) {

Expand Down Expand Up @@ -1182,18 +1177,18 @@ private String getId(String groupId, String artifactId, String type, String clas

public boolean updateExcludesInDeps(
MavenProject project, List<Dependency> dependencies, List<Dependency> transitiveDeps)
throws DependencyGraphBuilderException {
MavenProject original = session.getProjectBuildingRequest().getProject();
try {
session.getProjectBuildingRequest().setProject(project);
DependencyNode node =
dependencyGraphBuilder.buildDependencyGraph(session.getProjectBuildingRequest(), null);
boolean modified = false;
for (DependencyNode n2 : node.getChildren()) {
String artifactId2 = getId(n2.getArtifact());
throws DependencyCollectionException {
CollectRequest collectRequest = new CollectRequest(
new org.eclipse.aether.graph.Dependency(RepositoryUtils.toArtifact(project.getArtifact()), ""),
project.getRemoteProjectRepositories());
CollectResult result = repositorySystem.collectDependencies(session.getRepositorySession(), collectRequest);
boolean modified = false;
if (result.getRoot() != null) {
for (DependencyNode n2 : result.getRoot().getChildren()) {
String artifactId2 = getId(RepositoryUtils.toArtifact(n2.getArtifact()));

for (DependencyNode n3 : n2.getChildren()) {
Artifact artifact3 = n3.getArtifact();
Artifact artifact3 = RepositoryUtils.toArtifact(n3.getArtifact());
String artifactId3 = getId(artifact3);

// check if it really isn't in the list of original dependencies. Maven
Expand Down Expand Up @@ -1240,11 +1235,8 @@ public boolean updateExcludesInDeps(
}
}
}
return modified;
} finally {
// restore it
session.getProjectBuildingRequest().setProject(original);
}
return modified;
}

private boolean dependencyHasExclusion(Dependency dep, Artifact exclusionToCheck) {
Expand Down

0 comments on commit 741d7a2

Please sign in to comment.