Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linkage Checker to throw exception upon missing artifact #2105

Merged
merged 11 commits into from
Jun 18, 2021

Conversation

suztomo
Copy link
Contributor

@suztomo suztomo commented Jun 3, 2021

Fixes #2097

@google-cla google-cla bot added the cla: yes label Jun 3, 2021
@suztomo
Copy link
Contributor Author

suztomo commented Jun 3, 2021

Interesting. It's always freemarker, why?

Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact org.freemarker:freemarker:pom:2.3.30 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/freemarker/freemarker/2.3.30/freemarker-2.3.30.pom

for (UnresolvableArtifactProblem artifactProblem : artifactProblems) {
logger.warning(artifactProblem.toString());
}
throw new IOException("Could not resolve dependencies");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might break project with complex dependency tree such as Beam and spring-cloud-gcp.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed that these are not the case. Beam's usage (LinkageCheckerMain with "-a" option) does not use this code path. Spring-cloud-gcp's usage is through the enforcer rule, which uses ClassPathBuilder before calling LinkageChecker.

This constructor is used by Linkage Monitor and MaximumLinkageErrorsTest.

@suztomo
Copy link
Contributor Author

suztomo commented Jun 7, 2021

Todo: add test. What's a good artifact (that has missing transitive dependencies) to create a Bom instance?

@suztomo suztomo marked this pull request as ready for review June 7, 2021 14:41
@suztomo suztomo requested a review from elharo June 7, 2021 14:41
@@ -110,6 +111,20 @@ public static LinkageChecker create(Bom bom, Path exclusionFile)
classPathBuilder.resolve(managedDependencies, true, DependencyMediation.MAVEN);
ImmutableList<ClassPathEntry> classpath = classPathResult.getClassPath();

ImmutableList<UnresolvableArtifactProblem> artifactProblems =
classPathResult.getArtifactProblems();
Copy link
Contributor Author

@suztomo suztomo Jun 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The artifact problems were not not reported. For the Cloud SQL case, it was unclear why MaximumLinkageErrorsTest
fails GoogleCloudPlatform/cloud-sql-jdbc-socket-factory#507 (comment) until I ran it with the debugger.

@suztomo suztomo added the kokoro:run force run kokoro label Jun 9, 2021
@cloud-tools-for-java-team cloud-tools-for-java-team removed the kokoro:run force run kokoro label Jun 14, 2021
@suztomo suztomo merged commit 4e8dc71 into master Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Linkage Checker does not report paths to missing artifacts
3 participants