use of com.google.cloud.tools.opensource.dependencies.DependencyGraph in project cloud-opensource-java by GoogleCloudPlatform.
the class GradleDependencyMediationTest method testMediation_oneArtifactForEachVersionlessCoordinates.
@Test
public void testMediation_oneArtifactForEachVersionlessCoordinates() throws InvalidVersionSpecificationException {
DependencyGraph graph = new DependencyGraph(null);
// The old version comes first in the graph.list
graph.addPath(new DependencyPath(null).append(new Dependency(artifactA1, "compile")));
graph.addPath(new DependencyPath(null).append(new Dependency(artifactA2, "compile")));
// The duplicate shouldn't appear in the class path
graph.addPath(new DependencyPath(null).append(new Dependency(artifactB1, "compile")));
AnnotatedClassPath result = mediation.mediate(graph);
Truth.assertThat(result.getClassPath()).comparingElementsUsing(CLASS_PATH_ENTRY_TO_ARTIFACT).containsExactly(artifactA2, artifactB1).inOrder();
}
use of com.google.cloud.tools.opensource.dependencies.DependencyGraph in project cloud-opensource-java by GoogleCloudPlatform.
the class LinkageCheckerTest method resolveTransitiveDependencyPaths.
/**
* Returns the class path resolved for the transitive dependencies of {@code coordinates}.
*/
private ImmutableList<ClassPathEntry> resolveTransitiveDependencyPaths(String coordinates) throws IOException {
DependencyGraph dependencies = dependencyGraphBuilder.buildMavenDependencyGraph(new Dependency(new DefaultArtifact(coordinates), "compile"));
ImmutableList.Builder<ClassPathEntry> builder = ImmutableList.builder();
for (DependencyPath path : dependencies.list()) {
builder.add(new ClassPathEntry(path.getLeaf()));
}
return builder.build();
}
use of com.google.cloud.tools.opensource.dependencies.DependencyGraph in project cloud-opensource-java by GoogleCloudPlatform.
the class MavenDependencyMediationTest method testMediation_noDuplicates.
@Test
public void testMediation_noDuplicates() throws InvalidVersionSpecificationException {
DependencyGraph graph = new DependencyGraph(null);
// The old version comes first in the graph.list
graph.addPath(new DependencyPath(null).append(new Dependency(artifactA1, "compile")));
graph.addPath(new DependencyPath(null).append(new Dependency(artifactA2, "compile")));
// The duplicate shouldn't appear in the class path
graph.addPath(new DependencyPath(null).append(new Dependency(artifactA1, "compile")));
AnnotatedClassPath result = mediation.mediate(graph);
Truth.assertThat(result.getClassPath()).hasSize(1);
Truth.assertThat(result.getClassPath()).comparingElementsUsing(CLASS_PATH_ENTRY_TO_ARTIFACT).containsExactly(artifactA1);
}
use of com.google.cloud.tools.opensource.dependencies.DependencyGraph in project cloud-opensource-java by GoogleCloudPlatform.
the class MavenDependencyMediationTest method testMediation_oneArtifactForEachVersionlessCoordinates.
@Test
public void testMediation_oneArtifactForEachVersionlessCoordinates() throws InvalidVersionSpecificationException {
DependencyGraph graph = new DependencyGraph(null);
// The old version comes first in the graph.list
graph.addPath(new DependencyPath(null).append(new Dependency(artifactA1, "compile")));
graph.addPath(new DependencyPath(null).append(new Dependency(artifactA2, "compile")));
// The duplicate shouldn't appear in the class path
graph.addPath(new DependencyPath(null).append(new Dependency(artifactB1, "compile")));
AnnotatedClassPath result = mediation.mediate(graph);
Truth.assertThat(result.getClassPath()).comparingElementsUsing(CLASS_PATH_ENTRY_TO_ARTIFACT).containsExactly(artifactA1, artifactB1).inOrder();
}
use of com.google.cloud.tools.opensource.dependencies.DependencyGraph in project cloud-opensource-java by GoogleCloudPlatform.
the class LinkageCheckTask method createClassPathResult.
private ClassPathResult createClassPathResult(ResolvedConfiguration configuration) {
DependencyGraph dependencyGraph = createDependencyGraph(configuration);
AnnotatedClassPath annotatedClassPath = new AnnotatedClassPath();
for (DependencyPath path : dependencyGraph.list()) {
Artifact artifact = path.getLeaf();
annotatedClassPath.put(new ClassPathEntry(artifact), path);
}
return new ClassPathResult(annotatedClassPath, ImmutableList.of());
}
Aggregations