use of com.google.cloud.tools.opensource.classpath.ClassFile in project cloud-opensource-java by GoogleCloudPlatform.
the class LinkageMonitor method messageForNewErrors.
/**
* Returns a message on {@code snapshotProblems} that do not exist in {@code baselineProblems}.
*/
@VisibleForTesting
static String messageForNewErrors(Set<LinkageProblem> snapshotProblems, Set<LinkageProblem> baselineProblems, ClassPathResult classPathResult) {
Set<LinkageProblem> newProblems = Sets.difference(snapshotProblems, baselineProblems);
Builder<ClassPathEntry> problematicJars = ImmutableSet.builder();
ImmutableListMultimap<String, LinkageProblem> groupedBySymbolProblem = Multimaps.index(newProblems, problem -> problem.formatSymbolProblem());
StringBuilder message = new StringBuilder("Newly introduced problem" + (groupedBySymbolProblem.keySet().size() > 1 ? "s" : "") + ":\n");
for (String problem : groupedBySymbolProblem.keySet()) {
message.append(problem + "\n");
for (LinkageProblem linkageProblem : groupedBySymbolProblem.get(problem)) {
// This is null for ClassNotFound error.
if (linkageProblem.getTargetClass() != null) {
problematicJars.add(linkageProblem.getTargetClass().getClassPathEntry());
}
ClassFile sourceClass = linkageProblem.getSourceClass();
message.append(String.format(" referenced from %s (%s)\n", sourceClass.getBinaryName(), sourceClass.getClassPathEntry()));
problematicJars.add(sourceClass.getClassPathEntry());
}
}
message.append("\n");
message.append(classPathResult.formatDependencyPaths(problematicJars.build()));
return message.toString();
}
use of com.google.cloud.tools.opensource.classpath.ClassFile in project cloud-opensource-java by GoogleCloudPlatform.
the class LinkageMonitorTest method setup.
@Before
public void setup() throws IOException {
system = RepositoryUtility.newRepositorySystem();
session = RepositoryUtility.newSession(system);
methodNotFoundProblemFromA = new SymbolNotFoundProblem(new ClassFile(jarA, "com.abc.AAA"), new ClassFile(jarB, "io.grpc.protobuf.ProtoUtils"), new MethodSymbol("io.grpc.protobuf.ProtoUtils", "marshaller", "(Lcom/google/protobuf/Message;)Lio/grpc/MethodDescriptor$Marshaller;", false));
methodNotFoundProblemFromB = new SymbolNotFoundProblem(new ClassFile(jarA, "com.abc.BBB"), new ClassFile(jarB, "io.grpc.protobuf.ProtoUtils"), new MethodSymbol("io.grpc.protobuf.ProtoUtils", "marshaller", "(Lcom/google/protobuf/Message;)Lio/grpc/MethodDescriptor$Marshaller;", false));
}
use of com.google.cloud.tools.opensource.classpath.ClassFile in project cloud-opensource-java by GoogleCloudPlatform.
the class LinkageCheckTask method dependencyPathsOfProblematicJars.
private String dependencyPathsOfProblematicJars(ResolvedComponentResult componentResult, Set<LinkageProblem> symbolProblems) {
ImmutableSet.Builder<ClassPathEntry> problematicJars = ImmutableSet.builder();
for (LinkageProblem problem : symbolProblems) {
ClassFile targetClass = problem.getTargetClass();
if (targetClass != null) {
problematicJars.add(targetClass.getClassPathEntry());
}
ClassFile sourceClass = problem.getSourceClass();
problematicJars.add(sourceClass.getClassPathEntry());
}
return "Problematic artifacts in the dependency tree:\n" + dependencyPathToArtifacts(componentResult, problematicJars.build());
}
use of com.google.cloud.tools.opensource.classpath.ClassFile in project cloud-opensource-java by GoogleCloudPlatform.
the class FreemarkerTest method setUp.
@Before
public void setUp() {
Artifact artifact = new DefaultArtifact("com.google:foo:1.0.0").setFile(new File("foo/bar-1.2.3.jar"));
ClassPathEntry entry = new ClassPathEntry(artifact);
ImmutableSet<LinkageProblem> dummyProblems = ImmutableSet.of(new ClassNotFoundProblem(new ClassFile(entry, "abc.def.G"), new ClassSymbol("com.foo.Bar")));
symbolProblemTable = ImmutableMap.of(entry, dummyProblems);
}
Aggregations