Skip to content

Commit

Permalink
Make sure platform BOMs are collected when either descriptor or prope…
Browse files Browse the repository at this point in the history
…rties artifact is met first
  • Loading branch information
aloubyansky committed Jan 10, 2025
1 parent 8da6801 commit 3e7ebdf
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void addPlatformRelease(String propertyName, String propertyValue) {
final String platformKey = propertyName.substring(PROPERTY_PREFIX.length(), platformKeyStreamSep);
final String streamId = propertyName.substring(platformKeyStreamSep + 1, streamVersionSep);
final String version = propertyName.substring(streamVersionSep + 1);
allPlatformInfo.computeIfAbsent(platformKey, k -> new PlatformInfo(k)).getOrCreateStream(streamId).addIfNotPresent(
allPlatformInfo.computeIfAbsent(platformKey, PlatformInfo::new).getOrCreateStream(streamId).addIfNotPresent(
version,
() -> {
final PlatformReleaseInfo ri = new PlatformReleaseInfo(platformKey, streamId, version, propertyValue);
Expand All @@ -81,10 +81,7 @@ public void addPlatformDescriptor(String groupId, String artifactId, String clas
artifactId.substring(0,
artifactId.length() - BootstrapConstants.PLATFORM_DESCRIPTOR_ARTIFACT_ID_SUFFIX.length()),
version);
platformImports.computeIfAbsent(bomCoords, c -> {
platformBoms.add(bomCoords);
return new PlatformImport();
}).descriptorFound = true;
platformImports.computeIfAbsent(bomCoords, this::newPlatformImport).descriptorFound = true;
}

public void addPlatformProperties(String groupId, String artifactId, String classifier, String type, String version,
Expand All @@ -93,7 +90,7 @@ public void addPlatformProperties(String groupId, String artifactId, String clas
artifactId.substring(0,
artifactId.length() - BootstrapConstants.PLATFORM_PROPERTIES_ARTIFACT_ID_SUFFIX.length()),
version);
platformImports.computeIfAbsent(bomCoords, c -> new PlatformImport());
platformImports.computeIfAbsent(bomCoords, this::newPlatformImport);
importedPlatformBoms.computeIfAbsent(groupId, g -> new ArrayList<>());
if (!importedPlatformBoms.get(groupId).contains(bomCoords)) {
importedPlatformBoms.get(groupId).add(bomCoords);
Expand All @@ -117,6 +114,17 @@ public void addPlatformProperties(String groupId, String artifactId, String clas
}
}

/**
* This method is meant to be called when a new platform BOM import was detected.
*
* @param bom platform BOM coordinates
* @return new platform import instance
*/
private PlatformImport newPlatformImport(ArtifactCoords bom) {
platformBoms.add(bom);
return new PlatformImport();
}

public void setPlatformProperties(Map<String, String> platformProps) {
this.collectedProps.putAll(platformProps);
}
Expand Down

0 comments on commit 3e7ebdf

Please sign in to comment.