Skip to content

Linkage Checker to handle classifier in artifacts#2176

Merged
suztomo merged 5 commits intomasterfrom
classifier
Aug 11, 2021
Merged

Linkage Checker to handle classifier in artifacts#2176
suztomo merged 5 commits intomasterfrom
classifier

Conversation

@suztomo
Copy link
Copy Markdown
Contributor

@suztomo suztomo commented Aug 11, 2021

Fixes #2173

@google-cla google-cla bot added the cla: yes label Aug 11, 2021
@suztomo suztomo changed the title Gradle plugin to handle classifier in artifacts Linkage Checker to handle classifier in artifacts Aug 11, 2021
@suztomo suztomo requested a review from a team August 11, 2021 19:02
File file = artifact.getFile();
if (file != null && file.getName().endsWith(".jar")) {
String versionlessCoordinates = Artifacts.makeKey(artifact);
String versionlessCoordinates = Artifacts.makeKey(artifact) + artifact.getClassifier();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does getClassifier() return the colon prefix, too? Like ":test"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, it doesn't give a colon prefix. Let me add one. I think it's more clear.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added ":".

Copy link
Copy Markdown
Contributor

@dzou dzou left a comment

Choose a reason for hiding this comment

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

LGTM on my end, will let Elena a chance to review

LinkageChecker linkageChecker = LinkageChecker.create(bom);
ImmutableSet<LinkageProblem> linkageProblems = linkageChecker.findLinkageProblems();

// bom-with-classifier-artifacts contains com.google.cloud:goole-cloud-core:jar:tests:1.96.0.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// bom-with-classifier-artifacts contains com.google.cloud:goole-cloud-core:jar:tests:1.96.0.
// bom-with-classifier-artifacts contains com.google.cloud:google-cloud-core:jar:tests:1.96.0.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

graph.addPath(path);
}

Verify.verify(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is path != null equivalent to !node.getModuleArtifacts().isEmpty()? If so you may be able to just verify that condition instead which would allow you to avoid defining path outside the loop.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated this to check more earlier.

LinkageChecker linkageChecker = LinkageChecker.create(bom);
ImmutableSet<LinkageProblem> linkageProblems = linkageChecker.findLinkageProblems();

// bom-with-classifier-artifacts contains com.google.cloud:goole-cloud-core:jar:tests:1.96.0.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

graph.addPath(path);
}

Verify.verify(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated this to check more earlier.

return new Dependency(artifact, "compile");
}

private static DependencyGraph createDependencyGraph(ResolvedConfiguration configuration) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removing static because it now accesses getLogger.

return graph;
}

private static ClassPathResult createClassPathResult(ResolvedConfiguration configuration) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removing static because it accesses createDependencyGraph, which is now non-static.

parentPath == null
? new DependencyPath(artifactFrom(node))
: parentPath.append(dependencyFrom(node));
DependencyPath path = null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just reminder to define this in the loop if it is no longer needed outside.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This variable is needed outside.

@suztomo suztomo merged commit bddb324 into master Aug 11, 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 to work with artifacts with classifiers

3 participants