use of com.google.cloud.tools.opensource.dependencies.DependencyPath in project cloud-opensource-java by GoogleCloudPlatform.
the class MissingDependencyTest method testToString_optional.
@Test
public void testToString_optional() {
Artifact root = new DefaultArtifact("a:b:1");
Artifact foo = new DefaultArtifact("com.google:foo:1");
Artifact bar = new DefaultArtifact("com.google:bar:1");
DependencyPath pathRootFooBar = new DependencyPath(root).append(new Dependency(foo, "test", false)).append(new Dependency(bar, "compile", true));
MissingDependency missingDependency = new MissingDependency(pathRootFooBar);
assertEquals("The valid symbol is in com.google:bar:jar:1 at a:b:jar:1 / " + "com.google:foo:1 (test) / com.google:bar:1 (compile, optional) " + "but it was not selected because the path contains an optional dependency", missingDependency.toString());
}
use of com.google.cloud.tools.opensource.dependencies.DependencyPath in project cloud-opensource-java by GoogleCloudPlatform.
the class MissingDependencyTest method testToString_provided.
@Test
public void testToString_provided() {
Artifact root = new DefaultArtifact("a:b:1");
Artifact foo = new DefaultArtifact("com.google:foo:1");
Artifact bar = new DefaultArtifact("com.google:bar:1");
DependencyPath pathRootFooBar = new DependencyPath(root).append(new Dependency(foo, "test", false)).append(new Dependency(bar, "provided", false));
MissingDependency missingDependency = new MissingDependency(pathRootFooBar);
assertEquals("The valid symbol is in com.google:bar:jar:1 at a:b:jar:1 / " + "com.google:foo:1 (test) / com.google:bar:1 (provided) " + "but it was not selected because the path contains a provided-scope dependency", missingDependency.toString());
}
use of com.google.cloud.tools.opensource.dependencies.DependencyPath in project cloud-opensource-java by GoogleCloudPlatform.
the class AbstractMethodProblem method describe.
@Override
String describe(DependencyConflict conflict) {
DependencyPath pathToSelectedArtifact = conflict.getPathToSelectedArtifact();
Artifact selected = pathToSelectedArtifact.getLeaf();
String selectedCoordinates = Artifacts.toCoordinates(selected);
DependencyPath pathToArtifactThruSource = conflict.getPathToArtifactThruSource();
Artifact unselected = pathToArtifactThruSource.getLeaf();
String unselectedCoordinates = Artifacts.toCoordinates(unselected);
ClassFile supertype = getTargetClass();
return "Dependency conflict: " + selectedCoordinates + " defines incompatible version of " + supertype.getBinaryName() + " but " + unselectedCoordinates + " defines compatible one.\n" + " selected: " + pathToSelectedArtifact + "\n unselected: " + pathToArtifactThruSource;
}
use of com.google.cloud.tools.opensource.dependencies.DependencyPath in project cloud-opensource-java by GoogleCloudPlatform.
the class LinkageProblem method describe.
String describe(DependencyConflict conflict) {
DependencyPath pathToSelectedArtifact = conflict.getPathToSelectedArtifact();
Artifact selected = pathToSelectedArtifact.getLeaf();
String selectedCoordinates = Artifacts.toCoordinates(selected);
DependencyPath pathToArtifactThruSource = conflict.getPathToArtifactThruSource();
Artifact unselected = pathToArtifactThruSource.getLeaf();
String unselectedCoordinates = Artifacts.toCoordinates(unselected);
return "Dependency conflict: " + selectedCoordinates + " does not define " + getSymbol() + " but " + unselectedCoordinates + " defines it.\n" + " selected: " + pathToSelectedArtifact + "\n unselected: " + pathToArtifactThruSource;
}
use of com.google.cloud.tools.opensource.dependencies.DependencyPath in project cloud-opensource-java by GoogleCloudPlatform.
the class MavenDependencyMediation method mediate.
@Override
public AnnotatedClassPath mediate(DependencyGraph dependencyGraph) {
Set<Artifact> artifacts = new HashSet<>();
// Versionless coordinates plus classifier, if any
Set<String> alreadyFound = new HashSet<>();
AnnotatedClassPath annotatedClassPath = new AnnotatedClassPath();
List<DependencyPath> dependencyPaths = dependencyGraph.list();
for (DependencyPath dependencyPath : dependencyPaths) {
// DependencyPaths have items in level-order; nearest items come first.
Artifact artifact = dependencyPath.getLeaf();
File file = artifact.getFile();
if (file != null && file.getName().endsWith(".jar")) {
String versionlessCoordinates = Artifacts.makeKey(artifact) + ":" + artifact.getClassifier();
if (alreadyFound.add(versionlessCoordinates)) {
// Adds to artifacts when versionlessCoordinates are new.
artifacts.add(artifact);
}
if (artifacts.contains(artifact)) {
// We include multiple dependency paths to the first version of an artifact we see,
// but not paths to other versions of that artifact.
annotatedClassPath.put(new ClassPathEntry(artifact), dependencyPath);
}
}
}
return annotatedClassPath;
}
Aggregations