-
Notifications
You must be signed in to change notification settings - Fork 10
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
Support projects providing several artifacts #88
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do have to another pass in a bit to fully understand the variant logic
@@ -82,7 +81,7 @@ public class SpdxDocumentBuilder { | |||
|
|||
private final HashMap<ComponentIdentifier, LinkedHashSet<ComponentIdentifier>> tree = | |||
new LinkedHashMap<>(); | |||
private final Map<ComponentIdentifier, File> resolvedExternalArtifacts; | |||
private final Map<ComponentIdentifier, Collection<File>> resolvedExternalArtifacts; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using List
everywhere instead of Collection
would be nice. We don't plan on using a non-list anyway
Map<ComponentIdentifier, Collection<File>> results = new HashMap<>(); | ||
artifacts.forEach( | ||
(identifier, file) -> { | ||
if (results.containsKey(identifier.getComponentIdentifier())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section can be compressed down to:
results.getOrDefault(identifier.getComponentIdentifier(), new ArrayList<File>()).add(file)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But getOrDefault
does not put the defaultValue back into Map
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh right, yeah you have to add it in. oops
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think computeIfAbsent is what I actually wanted, it does the insert.
results.computeIfAbsent(identifier.getComponentIdentifier(), l -> new ArrayList<File>()).add(file)
private static Map<ComponentIdentifier, Collection<File>> fromResolvedArtifacts( | ||
Map<ComponentArtifactIdentifier, File> artifacts) { | ||
Map<ComponentIdentifier, Collection<File>> results = new HashMap<>(); | ||
artifacts.forEach( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this still needs to filter out project components (for #69)
@@ -289,7 +274,7 @@ private SpdxPackage createProjectPackage(ResolvedComponentResult resolvedCompone | |||
SpdxPackageBuilder builder = | |||
doc.createPackage( | |||
doc.getModelStore().getNextId(IdType.SpdxId, doc.getDocumentUri()), | |||
pi.getName(), | |||
pi.getName(), // TODO: name could be from file in case several files declared |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do variants have names? or is it all implicit?
|
||
spdxPackages.put(component.getId(), maybePackage.get()); | ||
// TODO: support createdPackages list if several packages created | ||
spdxPackages.put(component.getId(), createdPackages.get(0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is 0 expected to be the "main" variant?
This MR fixes cases when there are several artifacts for different platforms declared by one module (e.g.
kotlin-stdlib
) using gradle variants