51
51
import org .eclipse .aether .artifact .DefaultArtifact ;
52
52
import org .eclipse .aether .collection .CollectRequest ;
53
53
import org .eclipse .aether .graph .Dependency ;
54
+ import org .eclipse .aether .graph .DependencyNode ;
55
+ import org .eclipse .aether .graph .DependencyVisitor ;
54
56
import org .eclipse .aether .repository .RemoteRepository ;
55
57
import org .eclipse .aether .repository .RepositoryPolicy ;
56
58
import org .eclipse .aether .resolution .ArtifactRequest ;
@@ -223,7 +225,7 @@ private List<Artifact> resolvePlugin(Plugin plugin, Configuration config) {
223
225
224
226
if (config .verifyPluginDependencies ) {
225
227
// we need resolve all transitive dependencies
226
- result = resolvePluginArtifactsTransitive (pArtifact , pluginDependencies , config .verifyPomFiles );
228
+ result = resolvePluginArtifactsTransitive (pArtifact , pluginDependencies , config .dependencyFilter , config . verifyPomFiles );
227
229
} else {
228
230
// only resolve plugin artifact
229
231
List <org .eclipse .aether .artifact .Artifact > aeArtifacts = new ArrayList <>();
@@ -240,7 +242,7 @@ private List<Artifact> resolvePlugin(Plugin plugin, Configuration config) {
240
242
241
243
private List <org .eclipse .aether .artifact .Artifact > resolvePluginArtifactsTransitive (
242
244
org .eclipse .aether .artifact .Artifact artifact ,
243
- List <Dependency > dependencies , boolean verifyPomFiles ) {
245
+ List <Dependency > dependencies , SkipFilter dependencyFilter , boolean verifyPomFiles ) {
244
246
245
247
CollectRequest collectRequest = new CollectRequest (new Dependency (artifact , "runtime" ),
246
248
remotePluginRepositories );
@@ -252,12 +254,21 @@ private List<org.eclipse.aether.artifact.Artifact> resolvePluginArtifactsTransit
252
254
.recover (DependencyResolutionException .class , DependencyResolutionException ::getResult )
253
255
.get ();
254
256
255
- List <org .eclipse .aether .artifact .Artifact > result = new ArrayList <>(
256
- dependencyResult .getArtifactResults ().stream ()
257
- .map (aResult -> aResult .isResolved () ?
258
- aResult .getArtifact () :
259
- aResult .getRequest ().getArtifact ())
260
- .collect (Collectors .toList ()));
257
+ List <org .eclipse .aether .artifact .Artifact > result = new ArrayList <>();
258
+ dependencyResult .getRoot ().accept (new DependencyVisitor () {
259
+ @ Override
260
+ public boolean visitEnter (DependencyNode node ) {
261
+ if (node .getArtifact () != null && !dependencyFilter .shouldSkipDependency (node .getDependency ())) {
262
+ result .add (node .getArtifact ());
263
+ }
264
+ return true ;
265
+ }
266
+
267
+ @ Override
268
+ public boolean visitLeave (DependencyNode node ) {
269
+ return true ;
270
+ }
271
+ });
261
272
262
273
if (verifyPomFiles ) {
263
274
resolvePoms (result , remotePluginRepositories );
0 commit comments