Skip to content

Commit 3409e5a

Browse files
committed
Vendor the maven-dependency-tree v2.2 dependency
The package prefix for this code is now org.scijava.maven.plugin.dependency rather than org.apache.maven.shared.dependency. I also minimally updated the source code to conform to newer Maven 3.x APIs.
1 parent c3f2468 commit 3409e5a

File tree

45 files changed

+6515
-22
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+6515
-22
lines changed

pom.xml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,15 @@
143143

144144
<maven.version>3.0</maven.version>
145145
<maven-core.version>3.0</maven-core.version>
146-
<maven-dependency-tree.version>2.2</maven-dependency-tree.version>
147146
<maven-plugin-annotations.version>3.5</maven-plugin-annotations.version>
147+
<maven-resolver-api.version>1.9.18</maven-resolver-api.version>
148148
<maven-artifact-transfer.version>0.9.1</maven-artifact-transfer.version>
149149
<maven-common-artifact-filters.version>3.0.1</maven-common-artifact-filters.version>
150150
<plexus-interpolation.version>1.24</plexus-interpolation.version>
151151
<plexus-utils.version>3.1.0</plexus-utils.version>
152152
<org.eclipse.sisu.plexus.version>0.3.0</org.eclipse.sisu.plexus.version>
153153

154154
<hamcrest.version>1.3</hamcrest.version>
155-
156-
<!--
157-
Allow org.eclipse.aether:aether-util + org.apache.maven.shared:maven-artifact-transfer.
158-
-->
159-
<scijava.allowedDuplicateClasses>org.eclipse.aether.util.*</scijava.allowedDuplicateClasses>
160155
</properties>
161156

162157
<dependencies>
@@ -214,17 +209,18 @@
214209
</dependency>
215210

216211
<dependency>
217-
<groupId>org.apache.maven.shared</groupId>
218-
<artifactId>maven-artifact-transfer</artifactId>
212+
<groupId>org.apache.maven.resolver</groupId>
213+
<artifactId>maven-resolver-api</artifactId>
214+
<version>${maven-resolver-api.version}</version>
219215
</dependency>
216+
220217
<dependency>
221218
<groupId>org.apache.maven.shared</groupId>
222-
<artifactId>maven-common-artifact-filters</artifactId>
219+
<artifactId>maven-artifact-transfer</artifactId>
223220
</dependency>
224221
<dependency>
225222
<groupId>org.apache.maven.shared</groupId>
226-
<artifactId>maven-dependency-tree</artifactId>
227-
<version>${maven-dependency-tree.version}</version>
223+
<artifactId>maven-common-artifact-filters</artifactId>
228224
</dependency>
229225

230226
<dependency>

src/main/java/org/scijava/maven/plugin/AbstractSciJavaDependencyChecker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import java.util.Set;
3333

3434
import org.apache.maven.plugin.logging.Log;
35-
import org.apache.maven.shared.dependency.tree.DependencyNode;
35+
import org.scijava.maven.plugin.dependency.tree.DependencyNode;
3636

3737
/**
3838
* Abstract {@link SciJavaDependencyChecker} superclass, containing useful

src/main/java/org/scijava/maven/plugin/DependencyUtils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
import org.apache.maven.project.MavenProject;
4848
import org.apache.maven.project.MavenProjectBuilder;
4949
import org.apache.maven.project.ProjectBuildingException;
50-
import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder;
51-
import org.apache.maven.shared.dependency.tree.DependencyNode;
52-
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
53-
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
50+
import org.scijava.maven.plugin.dependency.graph.DependencyGraphBuilder;
51+
import org.scijava.maven.plugin.dependency.tree.DependencyNode;
52+
import org.scijava.maven.plugin.dependency.tree.DependencyTreeBuilder;
53+
import org.scijava.maven.plugin.dependency.tree.DependencyTreeBuilderException;
5454
import org.codehaus.plexus.PlexusContainer;
5555

5656
/**

src/main/java/org/scijava/maven/plugin/SciJavaDependencyChecker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
import java.util.Set;
3333

3434
import org.apache.maven.plugin.logging.Log;
35-
import org.apache.maven.shared.dependency.tree.DependencyNode;
36-
import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor;
35+
import org.scijava.maven.plugin.dependency.tree.DependencyNode;
36+
import org.scijava.maven.plugin.dependency.tree.traversal.DependencyNodeVisitor;
3737

3838
/**
3939
* {@link DependencyNodeVisitor} with convenience methods for logging and

src/main/java/org/scijava/maven/plugin/SnapshotFinder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import org.apache.maven.project.MavenProject;
4141
import org.apache.maven.project.MavenProjectBuilder;
4242
import org.apache.maven.project.ProjectBuildingException;
43-
import org.apache.maven.shared.dependency.tree.DependencyNode;
43+
import org.scijava.maven.plugin.dependency.tree.DependencyNode;
4444

4545
/**
4646
* {@link SciJavaDependencyChecker} implementation that fails when it encounters

src/main/java/org/scijava/maven/plugin/VerifyNoSnapshotsMojo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
import org.apache.maven.project.MavenProject;
4444
import org.apache.maven.project.MavenProjectBuilder;
4545
import org.apache.maven.project.ProjectBuildingException;
46-
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
46+
import org.scijava.maven.plugin.dependency.tree.DependencyTreeBuilder;
4747

4848
/**
4949
* Mojo wrapper for the {@link SnapshotFinder}.
@@ -72,7 +72,7 @@ public class VerifyNoSnapshotsMojo extends AbstractMojo {
7272

7373
/**
7474
* @component role =
75-
* "org.apache.maven.shared.dependency.tree.DependencyTreeBuilder"
75+
* "org.scijava.maven.plugin.dependency.tree.DependencyTreeBuilder"
7676
*/
7777
private DependencyTreeBuilder dependencyTreeBuilder;
7878

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*-
2+
* #%L
3+
* A plugin for managing SciJava-based projects.
4+
* %%
5+
* Copyright (C) 2014 - 2024 SciJava developers.
6+
* %%
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright notice,
11+
* this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
* #L%
28+
*/
29+
package org.scijava.maven.plugin.dependency.graph;
30+
31+
// Forked from org.apache.maven.shared:maven-dependency-tree:2.2
32+
33+
/*
34+
* Licensed to the Apache Software Foundation (ASF) under one
35+
* or more contributor license agreements. See the NOTICE file
36+
* distributed with this work for additional information
37+
* regarding copyright ownership. The ASF licenses this file
38+
* to you under the Apache License, Version 2.0 (the
39+
* "License"); you may not use this file except in compliance
40+
* with the License. You may obtain a copy of the License at
41+
*
42+
* http://www.apache.org/licenses/LICENSE-2.0
43+
*
44+
* Unless required by applicable law or agreed to in writing,
45+
* software distributed under the License is distributed on an
46+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
47+
* KIND, either express or implied. See the License for the
48+
* specific language governing permissions and limitations
49+
* under the License.
50+
*/
51+
52+
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
53+
import org.apache.maven.project.MavenProject;
54+
55+
import java.util.Collection;
56+
57+
/**
58+
* Maven project dependency graph builder API, neutral against Maven 2 or Maven 3.
59+
*
60+
* @author Hervé Boutemy
61+
* @since 2.0
62+
*/
63+
public interface DependencyGraphBuilder
64+
{
65+
/**
66+
* Build the dependency graph.
67+
*
68+
* @param project the project
69+
* @param filter artifact filter (can be <code>null</code>)
70+
* @return the dependency graph
71+
* @throws DependencyGraphBuilderException if some of the dependencies could not be resolved.
72+
*/
73+
DependencyNode buildDependencyGraph( MavenProject project, ArtifactFilter filter )
74+
throws DependencyGraphBuilderException;
75+
76+
/**
77+
* Build the dependency graph, with a hack to include dependencies contained in the reactor projects
78+
* but that are not yet compiled, which is the minimum prerequisite for Maven core's
79+
* ReactorReader to find them. Notice that this hack hasn't been done for Maven 2.
80+
* <p>Notice: If Maven core did collect instead of resolving dependencies (ie did not try to get the
81+
* artifacts but only the poms), probably this hack wouldn't be necessary even for people requiring
82+
* the dependency graph before compiling. TODO: for Maven 3, use Aether to collect dependencies.</p>
83+
*
84+
* @param project the project
85+
* @param filter artifact filter (can be <code>null</code>)
86+
* @param reactorProjects Collection of those projects contained in the reactor (can be <code>null</code>).
87+
* @return the dependency graph
88+
* @throws DependencyGraphBuilderException if some of the dependencies could not be resolved.
89+
*/
90+
DependencyNode buildDependencyGraph( MavenProject project, ArtifactFilter filter,
91+
Collection<MavenProject> reactorProjects )
92+
throws DependencyGraphBuilderException;
93+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*-
2+
* #%L
3+
* A plugin for managing SciJava-based projects.
4+
* %%
5+
* Copyright (C) 2014 - 2024 SciJava developers.
6+
* %%
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright notice,
11+
* this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
* #L%
28+
*/
29+
package org.scijava.maven.plugin.dependency.graph;
30+
31+
// Forked from org.apache.maven.shared:maven-dependency-tree:2.2
32+
33+
/*
34+
* Licensed to the Apache Software Foundation (ASF) under one
35+
* or more contributor license agreements. See the NOTICE file
36+
* distributed with this work for additional information
37+
* regarding copyright ownership. The ASF licenses this file
38+
* to you under the Apache License, Version 2.0 (the
39+
* "License"); you may not use this file except in compliance
40+
* with the License. You may obtain a copy of the License at
41+
*
42+
* http://www.apache.org/licenses/LICENSE-2.0
43+
*
44+
* Unless required by applicable law or agreed to in writing,
45+
* software distributed under the License is distributed on an
46+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
47+
* KIND, either express or implied. See the License for the
48+
* specific language governing permissions and limitations
49+
* under the License.
50+
*/
51+
52+
/**
53+
* Indicates that a Maven project's dependency graph cannot be resolved.
54+
*
55+
* @author Hervé Boutemy
56+
* @since 2.0
57+
*/
58+
public class DependencyGraphBuilderException
59+
extends Exception
60+
{
61+
private static final long serialVersionUID = -7428777046707410949L;
62+
63+
// constructors -----------------------------------------------------------
64+
65+
/**
66+
* @param message Message indicating why dependency graph could not be resolved.
67+
*/
68+
public DependencyGraphBuilderException( String message )
69+
{
70+
super( message );
71+
}
72+
73+
/**
74+
* @param message Message indicating why dependency graph could not be resolved.
75+
* @param cause Throwable indicating at which point the graph failed to be resolved.
76+
*/
77+
public DependencyGraphBuilderException( String message, Throwable cause )
78+
{
79+
super( message, cause );
80+
}
81+
}

0 commit comments

Comments
 (0)