rfscholte commented on code in PR #1571:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/1571#discussion_r2662538536


##########
src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java:
##########
@@ -479,6 +502,38 @@ private Set<Artifact> 
resolve(Set<org.eclipse.aether.artifact.Artifact> artifact
         return resolvedArtifacts;
     }
 
+    private Set<Artifact> collectArtifacts(MavenProject project) throws 
DependencyResolutionException {
+        if (graphRoots == null || graphRoots.isEmpty()) {
+            return project.getArtifacts();
+        } else {
+            List<DependencyMatcher> filterMatchers =
+                    
graphRoots.stream().map(GraphRootMatcher::new).collect(Collectors.toList());
+
+            DependencyMatcher subTreeMatcher = new 
OrDependencyMatcher(filterMatchers);
+
+            Set<Artifact> artifacts = new HashSet<>();
+            for (Dependency dep : project.getDependencies()) {
+                if (subTreeMatcher.matches(dep)) {
+                    artifacts.addAll(resolveDependencyArtifacts(dep));
+                }
+            }
+            return artifacts;
+        }
+    }
+
+    private Set<Artifact> resolveDependencyArtifacts(Dependency root) throws 
DependencyResolutionException {
+        org.eclipse.aether.graph.Dependency dependency = 
RepositoryUtils.toDependency(
+                root, 
session.getRepositorySession().getArtifactTypeRegistry());
+
+        List<RemoteRepository> remoteRepositories =
+                
RepositoryUtils.toRepos(session.getProjectBuildingRequest().getRemoteRepositories());
+
+        Collection<org.eclipse.aether.artifact.Artifact> depArtifacts =

Review Comment:
   The project dependencies have already been resolved, as the goal of the 
final Mojo contains `requiresDependencyResolution = ResolutionScope.TEST`. So 
it is actually re-resolving the dependencies. The MavenProject doesn't provide 
the graph, hence the need ask for the graph user maven artifact resolver.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to