diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/catalog/processor/ExtensionProcessor.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/catalog/processor/ExtensionProcessor.java index ebf2d99790dab..e5559a49c27e4 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/catalog/processor/ExtensionProcessor.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/catalog/processor/ExtensionProcessor.java @@ -2,15 +2,18 @@ import static io.quarkus.registry.catalog.Extension.*; +import io.quarkus.maven.ArtifactCoords; import io.quarkus.registry.catalog.Extension; import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.stream.Collectors; public final class ExtensionProcessor { private static final String STABLE_STATS = "stable"; + private static final String QUARKUS_BOM_ARTIFACT_ID = "quarkus-bom"; public static final String PROVIDES_CODE_TAG = "code"; public enum CodestartKind { @@ -55,6 +58,17 @@ public static String getCodestartName(Extension extension) { return getMetadataValue(extension, MD_NESTED_CODESTART_NAME).asString(); } + public static Optional getBom(Extension extension) { + if (extension == null || extension.getOrigins() == null || extension.getOrigins().isEmpty()) { + return Optional.empty(); + } + return Optional.of(extension.getOrigins().get(0).getBom()); + } + + public static Optional getNonQuarkusBomOnly(Extension extension) { + return getBom(extension).filter(p -> !p.getArtifactId().equals(QUARKUS_BOM_ARTIFACT_ID)); + } + public static List getCodestartLanguages(Extension extension) { return getMetadataValue(extension, MD_NESTED_CODESTART_LANGUAGES).asStringList(); } diff --git a/integration-tests/devtools/src/test/java/io/quarkus/platform/catalog/ExtensionProcessorTest.java b/integration-tests/devtools/src/test/java/io/quarkus/platform/catalog/ExtensionProcessorTest.java index b464f23e3be65..a3ac93d213302 100644 --- a/integration-tests/devtools/src/test/java/io/quarkus/platform/catalog/ExtensionProcessorTest.java +++ b/integration-tests/devtools/src/test/java/io/quarkus/platform/catalog/ExtensionProcessorTest.java @@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test; import io.quarkus.devtools.testing.PlatformAwareTestBase; +import io.quarkus.maven.ArtifactKey; import io.quarkus.platform.catalog.processor.ExtensionProcessor; import io.quarkus.registry.catalog.Extension; import io.quarkus.registry.catalog.ExtensionCatalog; @@ -32,6 +33,21 @@ void testRESTEasyMetadata() { assertThat(extensionProcessor.getGuide()).isEqualTo("https://quarkus.io/guides/rest-json"); } + @Test + void testGetBom() { + final ExtensionCatalog catalog = getExtensionsCatalog(); + final Extension kotlin = findExtension(catalog, "quarkus-kotlin"); + assertThat(ExtensionProcessor.getBom(kotlin).get().getKey()) + .isEqualTo(ArtifactKey.fromString("io.quarkus:quarkus-bom::pom")); + } + + @Test + void testGetNonQuarkusBomOnly() { + final ExtensionCatalog catalog = getExtensionsCatalog(); + final Extension kotlin = findExtension(catalog, "quarkus-kotlin"); + assertThat(ExtensionProcessor.getNonQuarkusBomOnly(kotlin)).isEmpty(); + } + @Test void testKotlinMetadata() { final ExtensionCatalog catalog = getExtensionsCatalog();