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

Remove duplicates when resolving Gradle dependencies from Node #1566

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions lib/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6083,11 +6083,24 @@ export async function createMultiXBom(pathList, options) {
) {
parentSubComponents.push(bomData.parentComponent);
}
// Retain metadata.component.components
// Retain metadata.component.components, but add duplicates to the list of current components
// and removing them from metadata.component.components -- the components are merged later
if (bomData.parentComponent.components?.length) {
parentSubComponents = parentSubComponents.concat(
bomData.parentComponent.components,
);
let bomSubComponents = bomData.parentComponent.components;
if (["true", "1"].includes(process.env.GRADLE_RESOLVE_FROM_NODE)) {
const allRefs = components.map((c) => c["bom-ref"]);
const duplicateComponents = bomSubComponents.filter((c) =>
allRefs.includes(c["bom-ref"]),
);
components = components.concat(duplicateComponents);
const duplicateComponentRefs = duplicateComponents.map(
(c) => c["bom-ref"],
);
bomSubComponents = bomSubComponents.filter(
(c) => !duplicateComponentRefs.includes(c["bom-ref"]),
);
}
parentSubComponents = parentSubComponents.concat(bomSubComponents);
delete bomData.parentComponent.components;
}
}
Expand Down
Loading