Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ public void execute() throws MojoExecutionException {

Collection<org.eclipse.aether.graph.Dependency> actualDependencies;
try {
actualDependencies = resolverUtil.collectDependencies(
actualDependencies = resolverUtil.collectDependenciesWithDirectDependencies(
null,
RepositoryUtils.toDependency(currentCoordinates.getDependency(), artifactTypeRegistry)
.setExclusions(null));
} catch (DependencyCollectionException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import javax.inject.Singleton;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
Expand Down Expand Up @@ -86,11 +87,23 @@ public ResolverUtil(RepositorySystem repositorySystem, Provider<MavenSession> ma
* @return a resolved dependencies collections
*/
public Collection<Dependency> collectDependencies(Dependency root) throws DependencyCollectionException {
return collectDependenciesWithDirectDependencies(root);
}

/**
* Collects the transitive dependencies.
*
* @param root a root dependency for collections
* @return a resolved dependencies collections
*/
public Collection<Dependency> collectDependenciesWithDirectDependencies(Dependency root, Dependency... dependencies)
throws DependencyCollectionException {

MavenSession session = mavenSessionProvider.get();

CollectRequest request =
new CollectRequest(root, session.getCurrentProject().getRemoteProjectRepositories());
Arrays.stream(dependencies).forEach(request::addDependency);
CollectResult result = repositorySystem.collectDependencies(session.getRepositorySession(), request);

PreorderNodeListGenerator nodeListGenerator = new PreorderNodeListGenerator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void testShallNotReportInvalidExclusionForWildcardGroupIdAndArtifactId(AnalyzeEx
dependencyWithWildcardExclusion.addExclusion(exclusion("*", "*"));
when(project.getDependencies()).thenReturn(Collections.singletonList(dependencyWithWildcardExclusion));

when(resolverUtil.collectDependencies(any()))
when(resolverUtil.collectDependenciesWithDirectDependencies(any(), any()))
.thenReturn(Collections.singletonList(new org.eclipse.aether.graph.Dependency(
new DefaultArtifact("whatever", "ok", "jar", "1.0"), "")));

Expand Down Expand Up @@ -168,7 +168,7 @@ void testShallNotLogWhenExclusionIsValid(AnalyzeExclusionsMojo mojo) throws Exce
dependencies.add(dependency);
when(project.getDependencies()).thenReturn(dependencies);

when(resolverUtil.collectDependencies(any()))
when(resolverUtil.collectDependenciesWithDirectDependencies(any(), any()))
.thenReturn(Collections.singletonList(
new org.eclipse.aether.graph.Dependency(new DefaultArtifact("ok", "ok", "jar", "1.0"), "")));

Expand Down
Loading