Skip to content

Commit

Permalink
avoid duplication descriptors in PlatformImportsImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
cdsap committed Oct 28, 2024
1 parent fcc7889 commit f9b290a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ 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 -> new PlatformImport()).descriptorFound = true;
platformBoms.add(bomCoords);
platformImports.computeIfAbsent(bomCoords, c -> {
platformBoms.add(bomCoords);
return new PlatformImport();
}).descriptorFound = true;
}

public void addPlatformProperties(String groupId, String artifactId, String classifier, String type, String version,
Expand All @@ -92,8 +94,10 @@ public void addPlatformProperties(String groupId, String artifactId, String clas
artifactId.length() - BootstrapConstants.PLATFORM_PROPERTIES_ARTIFACT_ID_SUFFIX.length()),
version);
platformImports.computeIfAbsent(bomCoords, c -> new PlatformImport());
importedPlatformBoms.computeIfAbsent(groupId, g -> new ArrayList<>()).add(bomCoords);

importedPlatformBoms.computeIfAbsent(groupId, g -> new ArrayList<>());
if (!importedPlatformBoms.get(groupId).contains(bomCoords)) {
importedPlatformBoms.get(groupId).add(bomCoords);
}
final Properties props = new Properties();
try (InputStream is = Files.newInputStream(propsPath)) {
props.load(is);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ public void multiplePlatformReleaseInTheSameStream() throws Exception {
GACTV.fromString("io.playground:acme-bom::pom:2.2.2")))));
}

@Test
public void duplicatePlatformDescriptorsAreIgnored() {
final PlatformImportsImpl pi = new PlatformImportsImpl();
pi.addPlatformDescriptor("io.playground", "acme-bom-quarkus-platform-descriptor", "", "", "1.1");
pi.addPlatformDescriptor("io.playground", "acme-bom-quarkus-platform-descriptor", "", "", "1.1");
assertEquals(1, pi.getImportedPlatformBoms().size());
}

private PlatformProps newPlatformProps() throws IOException {
final PlatformProps p = new PlatformProps();
platformProps.add(p);
Expand Down

0 comments on commit f9b290a

Please sign in to comment.