From 4514310540c2308a75028a9fe8af0cd46d9e3c7f Mon Sep 17 00:00:00 2001 From: Alexey Loubyansky Date: Fri, 7 Jan 2022 15:53:11 +0100 Subject: [PATCH] Fixed platform stream selection when platform key is null --- ...amStreamCoordsWithNullPlatformKeyTest.java | 76 +++++++++++++++++++ .../registry/ExtensionCatalogResolver.java | 6 +- 2 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 independent-projects/tools/devtools-testing/src/test/java/io/quarkus/devtools/project/create/UpstreamStreamCoordsWithNullPlatformKeyTest.java diff --git a/independent-projects/tools/devtools-testing/src/test/java/io/quarkus/devtools/project/create/UpstreamStreamCoordsWithNullPlatformKeyTest.java b/independent-projects/tools/devtools-testing/src/test/java/io/quarkus/devtools/project/create/UpstreamStreamCoordsWithNullPlatformKeyTest.java new file mode 100644 index 0000000000000..536df0397f134 --- /dev/null +++ b/independent-projects/tools/devtools-testing/src/test/java/io/quarkus/devtools/project/create/UpstreamStreamCoordsWithNullPlatformKeyTest.java @@ -0,0 +1,76 @@ +package io.quarkus.devtools.project.create; + +import io.quarkus.devtools.testing.registry.client.TestRegistryClientBuilder; +import io.quarkus.maven.ArtifactCoords; +import io.quarkus.registry.catalog.PlatformStreamCoords; +import java.nio.file.Path; +import java.util.List; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +public class UpstreamStreamCoordsWithNullPlatformKeyTest extends MultiplePlatformBomsTestBase { + + private static final String DOWNSTREAM_PLATFORM_KEY = "io.downstream.platform"; + private static final String UPSTREAM_PLATFORM_KEY = "io.upstream.platform"; + + @BeforeAll + public static void setup() throws Exception { + TestRegistryClientBuilder.newInstance() + //.debug() + .baseDir(configDir()) + // registry + .newRegistry("downstream.registry.test") + .recognizedQuarkusVersions("*-downstream") + // platform key + .newPlatform(DOWNSTREAM_PLATFORM_KEY) + .newStream("1.0") + // 1.0.4 release + .newRelease("1.1.1-downstream") + .quarkusVersion("1.1.1-downstream") + .upstreamQuarkusVersion("1.1.1") + // default bom including quarkus-core + essential metadata + .addCoreMember() + // foo platform member + .newMember("acme-a-bom").addExtension("io.acme", "ext-a", "1.1.1-downstream").release() + .stream().platform().registry() + .clientBuilder() + .newRegistry("upstream.registry.test") + // platform key + .newPlatform(UPSTREAM_PLATFORM_KEY) + // 2.0 STREAM + .newStream("2.0") + // 2.0.5 release + .newRelease("2.0.5") + .quarkusVersion("2.0.5") + // default bom including quarkus-core + essential metadata + .addCoreMember() + .newMember("acme-a-bom").addExtension("io.acme", "ext-a", "2.0.5").release().stream().platform() + // 1.0 STREAM + .newStream("1.0") + .newRelease("1.1.1") + .quarkusVersion("1.1.1") + // default bom including quarkus-core + essential metadata + .addCoreMember() + .newMember("acme-a-bom").addExtension("io.acme", "ext-a", "1.1.1") + .registry() + .clientBuilder() + .build(); + + enableRegistryClient(); + } + + protected String getMainPlatformKey() { + return UPSTREAM_PLATFORM_KEY; + } + + @Test + public void createUsingStream2_0() throws Exception { + final Path projectDir = newProjectDir("created-using-upstream-2.0"); + createProject(projectDir, new PlatformStreamCoords(null, "2.0"), List.of("ext-a")); + + assertModel(projectDir, + List.of(mainPlatformBom(), platformMemberBomCoords("acme-a-bom")), + List.of(new ArtifactCoords("io.acme", "ext-a", null)), + "2.0.5"); + } +} diff --git a/independent-projects/tools/registry-client/src/main/java/io/quarkus/registry/ExtensionCatalogResolver.java b/independent-projects/tools/registry-client/src/main/java/io/quarkus/registry/ExtensionCatalogResolver.java index 0643b0f6dce45..66c3d75b512af 100644 --- a/independent-projects/tools/registry-client/src/main/java/io/quarkus/registry/ExtensionCatalogResolver.java +++ b/independent-projects/tools/registry-client/src/main/java/io/quarkus/registry/ExtensionCatalogResolver.java @@ -489,7 +489,7 @@ public ExtensionCatalog resolveExtensionCatalog(PlatformStreamCoords streamCoord PlatformStream stream = null; int registryIndex = 0; - while (registryIndex < registries.size()) { + while (registryIndex < registries.size() && stream == null) { final RegistryExtensionResolver qer = registries.get(registryIndex++); final PlatformCatalog platforms = qer.resolvePlatformCatalog(); if (platforms == null) { @@ -508,8 +508,10 @@ public ExtensionCatalog resolveExtensionCatalog(PlatformStreamCoords streamCoord continue; } stream = platform.getStream(streamId); + if (stream != null) { + break; + } } - break; } if (stream == null) {