Set<Artifact> (DependencyResolutionResult dependencyResolutionResult, boolean addUnresolvedNodes) { Map<Dependency, Artifact> winnerDependencyMap = new IdentityHashMap<>(); Set<Artifact> artifacts = new LinkedHashSet<>(); Set<Dependency> addedDependencies = Collections.newSetFromMap(new IdentityHashMap<>()); resolveConflicts(dependencyResolutionResult, winnerDependencyMap); if (dependencyResolutionResult.getDependencyGraph() != null) { dependencyResolutionResult.getDependencyGraph().getChildren(); } for (Dependency dependency : dependencyResolutionResult.getDependencies()) { Artifact artifact = dependency == null ? null : winnerDependencyMap.get(dependency); if (artifact != null) { addedDependencies.add(dependency); artifacts.add(artifact); resolveAsModule(artifact); } } //if any syntax error presents in pom.xml we may not get dependencies via getDependencies, but they are in dependencyGraph. // we need to BFS this graph and add dependencies if (addUnresolvedNodes) { Queue<org.eclipse.aether.graph.DependencyNode> queue = new ArrayDeque<>(dependencyResolutionResult.getDependencyGraph().getChildren()); while (!queue.isEmpty()) { org.eclipse.aether.graph.DependencyNode node = queue.poll(); queue.addAll(node.getChildren()); Dependency dependency = node.getDependency(); if (dependency == null || !addedDependencies.add(dependency)) { continue; } Artifact artifact = winnerDependencyMap.get(dependency); if (artifact != null) { addedDependencies.add(dependency); //todo: properly resolve order artifacts.add(artifact); resolveAsModule(artifact); } } } return artifacts; }