diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/tools/ToolsUtils.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/tools/ToolsUtils.java index 8e2fc59613cf6d..8414634cc5ff02 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/tools/ToolsUtils.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/tools/ToolsUtils.java @@ -14,6 +14,7 @@ import java.io.IOException; import java.nio.file.Path; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -115,11 +116,41 @@ public static ExtensionCatalog resolvePlatformDescriptorDirectly(String bomGroup throw new RuntimeException("Failed to resolve the default platform JSON descriptor", e); } } + ExtensionCatalog catalog; try { - return JsonCatalogMapperHelper.deserialize(platformJson, JsonExtensionCatalog.class); + catalog = JsonCatalogMapperHelper.deserialize(platformJson, JsonExtensionCatalog.class); } catch (IOException e) { throw new RuntimeException("Failed to deserialize extension catalog " + platformJson, e); } + Map md = catalog.getMetadata(); + if (md != null) { + Object o = md.get("platform-release"); + if (o instanceof Map) { + Object members = ((Map) o).get("members"); + if (members instanceof Collection) { + final Collection memberList = (Collection) members; + final List catalogs = new ArrayList<>(memberList.size()); + for (Object m : memberList) { + if (m instanceof String && !catalog.getId().equals(m)) { + try { + final ArtifactCoords coords = ArtifactCoords.fromString((String) m); + catalogCoords = new DefaultArtifact(coords.getGroupId(), coords.getArtifactId(), + coords.getClassifier(), coords.getType(), coords.getVersion()); + log.debug("Resolving platform descriptor %s", catalogCoords); + final Path jsonPath = artifactResolver.resolve(catalogCoords).getArtifact().getFile().toPath(); + catalogs.add(JsonCatalogMapperHelper.deserialize(jsonPath, JsonExtensionCatalog.class)); + } catch (Exception e) { + log.warn("Failed to resolve member catalog " + m, e); + } + } else { + catalogs.add(catalog); + } + } + catalog = JsonCatalogMerger.merge(catalogs); + } + } + } + return catalog; } public static ExtensionCatalog mergePlatforms(List platforms, MavenArtifactResolver artifactResolver) {