@Test public void getDependencyGraph() throws URISyntaxException { MavenPomParser parser = new MavenPomParser(); String plyUtilPath = FileUtil.pathFromParts(PlyUtil.LOCAL_PROJECT_DIR.getAbsolutePath(), ".."); if (!plyUtilPath.contains("ply-util")) { plyUtilPath = plyUtilPath.replace(".ply", FileUtil.pathFromParts("ply-util", ".ply")); } String repoPath = FileUtil.pathFromParts(plyUtilPath, "src", "test", "resources", "mock-mvn-repo"); RepositoryAtom mockRepo = new RepositoryAtom(repoPath, new URI("file: MavenPom pom = parser.parsePom("file: List<DependencyAtom> deps = Deps.parse(pom.dependencies, null); assertEquals(3, deps.size()); Map<DependencyAtom, List<DependencyAtom>> synthetic = new HashMap<DependencyAtom, List<DependencyAtom>>(1); for (DependencyAtom atom : deps) { if ("slf4j-api".equals(atom.name)) { synthetic.put(atom, Collections.<DependencyAtom>emptyList()); } } DirectedAcyclicGraph<Dep> graph = Deps.getDependencyGraph(deps, Collections.<DependencyAtom>emptySet(), new RepositoryRegistry(mockRepo, null, synthetic)); List<Vertex<Dep>> resolved = graph.getVertices(); assertEquals(3, resolved.size()); synthetic = new HashMap<DependencyAtom, List<DependencyAtom>>(1); for (DependencyAtom atom : deps) { if ("slf4j-api".equals(atom.name)) { List<DependencyAtom> slf4jDependencies = new ArrayList<DependencyAtom>(1); slf4jDependencies.add(new DependencyAtom("stax", "stax-api", "1.0.1")); synthetic.put(atom, slf4jDependencies); } } graph = Deps.getDependencyGraph(deps, Collections.<DependencyAtom>emptySet(), new RepositoryRegistry(mockRepo, null, synthetic)); resolved = graph.getVertices(); assertEquals(4, resolved.size()); Set<DependencyAtom> exclusions = new HashSet<DependencyAtom>(1); exclusions.add(new DependencyAtom("stax", "stax-api", "1.0.1")); graph = Deps.getDependencyGraph(deps, exclusions, new RepositoryRegistry(mockRepo, null, synthetic)); resolved = graph.getVertices(); assertEquals(3, resolved.size()); }
public static DirectedAcyclicGraph<Dep> getDependencyGraph(List<DependencyAtom> dependencyAtoms, Set<DependencyAtom> exclusionAtoms, RepositoryRegistry repositoryRegistry) { return getDependencyGraph(dependencyAtoms, exclusionAtoms, repositoryRegistry, null, true); }
Deps { public static DirectedAcyclicGraph<Dep> getDependencyGraph(List<DependencyAtom> dependencyAtoms, Set<DependencyAtom> exclusionAtoms, RepositoryRegistry repositoryRegistry) { return getDependencyGraph(dependencyAtoms, exclusionAtoms, repositoryRegistry, null, true); } }
Deps { public static DirectedAcyclicGraph<Dep> getDependencyGraph(List<DependencyAtom> dependencyAtoms, Set<DependencyAtom> exclusionAtoms, RepositoryRegistry repositoryRegistry) { return getDependencyGraph(dependencyAtoms, exclusionAtoms, repositoryRegistry, null, true); } private  Deps(); }
Deps { public static DirectedAcyclicGraph<Dep> getDependencyGraph(List<DependencyAtom> dependencyAtoms, Set<DependencyAtom> exclusionAtoms, RepositoryRegistry repositoryRegistry) { return getDependencyGraph(dependencyAtoms, exclusionAtoms, repositoryRegistry, null, true); } private  Deps(); static DependencyAtom getMinimumVersion(DependencyAtom left, DependencyAtom right); static DirectedAcyclicGraph<Dep> getDependencyGraph(List<DependencyAtom> dependencyAtoms,
                                                               Set<DependencyAtom> exclusionAtoms,
                                                               RepositoryRegistry repositoryRegistry); static DirectedAcyclicGraph<Dep> getDependencyGraph(List<DependencyAtom> dependencyAtoms,
                                                               Set<DependencyAtom> exclusionAtoms,
                                                               RepositoryRegistry repositoryRegistry,
                                                               String classifier,
                                                               boolean failMissingDependency); static DirectedAcyclicGraph<Dep> getDependencyGraph(List<DependencyAtom> dependencyAtoms,
                                                               Set<DependencyAtom> exclusionAtoms,
                                                               RepositoryRegistry repositoryRegistry,
                                                               String classifier, boolean failMissingDependency,
                                                               ConflictingVersionVisitor conflictingVersionVisitor); static String getPathAsString(Vertex<Dep> vertex, DependencyAtom dependencyAtom); static List<DependencyAtom> parse(PropFile dependencies, String classifier); static DependencyAtom parse(Prop dependencyProp); static List<DependencyAtom> parseExclusions(PropFile exclusions, String classifier); static PropFile convertToResolvedPropertiesFile(DirectedAcyclicGraph<Dep> graph); static PropFile getResolvedProperties(boolean nullOnFNF); static PropFile getResolvedProperties(File projectConfigDir, Scope scope, boolean nullOnFNF); static String getClasspath(PropFile resolvedDependencies, String ... supplemental); static DependencyAtom getProjectDep(); static DependencyAtom getDepFromParts(String namespace, String name, String version, String artifactName); static String getArtifactName(String name, String version, String classifier, String packaging); static String getDependencyDirectoryPathForRepo(DependencyAtom dependencyAtom, RepositoryAtom repositoryAtom); static String getDependencyArtifactPathForRepo(DependencyAtom dependencyAtom, RepositoryAtom repositoryAtom); static void addChangedDependency(Scope scope, DependencyAtom dependency); }
Deps { public static DirectedAcyclicGraph<Dep> getDependencyGraph(List<DependencyAtom> dependencyAtoms, Set<DependencyAtom> exclusionAtoms, RepositoryRegistry repositoryRegistry) { return getDependencyGraph(dependencyAtoms, exclusionAtoms, repositoryRegistry, null, true); } private  Deps(); static DependencyAtom getMinimumVersion(DependencyAtom left, DependencyAtom right); static DirectedAcyclicGraph<Dep> getDependencyGraph(List<DependencyAtom> dependencyAtoms,
                                                               Set<DependencyAtom> exclusionAtoms,
                                                               RepositoryRegistry repositoryRegistry); static DirectedAcyclicGraph<Dep> getDependencyGraph(List<DependencyAtom> dependencyAtoms,
                                                               Set<DependencyAtom> exclusionAtoms,
                                                               RepositoryRegistry repositoryRegistry,
                                                               String classifier,
                                                               boolean failMissingDependency); static DirectedAcyclicGraph<Dep> getDependencyGraph(List<DependencyAtom> dependencyAtoms,
                                                               Set<DependencyAtom> exclusionAtoms,
                                                               RepositoryRegistry repositoryRegistry,
                                                               String classifier, boolean failMissingDependency,
                                                               ConflictingVersionVisitor conflictingVersionVisitor); static String getPathAsString(Vertex<Dep> vertex, DependencyAtom dependencyAtom); static List<DependencyAtom> parse(PropFile dependencies, String classifier); static DependencyAtom parse(Prop dependencyProp); static List<DependencyAtom> parseExclusions(PropFile exclusions, String classifier); static PropFile convertToResolvedPropertiesFile(DirectedAcyclicGraph<Dep> graph); static PropFile getResolvedProperties(boolean nullOnFNF); static PropFile getResolvedProperties(File projectConfigDir, Scope scope, boolean nullOnFNF); static String getClasspath(PropFile resolvedDependencies, String ... supplemental); static DependencyAtom getProjectDep(); static DependencyAtom getDepFromParts(String namespace, String name, String version, String artifactName); static String getArtifactName(String name, String version, String classifier, String packaging); static String getDependencyDirectoryPathForRepo(DependencyAtom dependencyAtom, RepositoryAtom repositoryAtom); static String getDependencyArtifactPathForRepo(DependencyAtom dependencyAtom, RepositoryAtom repositoryAtom); static void addChangedDependency(Scope scope, DependencyAtom dependency);  }