Skip to content

Commit

Permalink
Add helper to get extension bom to devtools
Browse files Browse the repository at this point in the history
  • Loading branch information
ia3andy committed Jul 23, 2021
1 parent bc33d94 commit 6ca3492
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -55,6 +58,17 @@ public static String getCodestartName(Extension extension) {
return getMetadataValue(extension, MD_NESTED_CODESTART_NAME).asString();
}

public static Optional<ArtifactCoords> 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<ArtifactCoords> getNonQuarkusBomOnly(Extension extension) {
return getBom(extension).filter(p -> !p.getArtifactId().equals(QUARKUS_BOM_ARTIFACT_ID));
}

public static List<String> getCodestartLanguages(Extension extension) {
return getMetadataValue(extension, MD_NESTED_CODESTART_LANGUAGES).asStringList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down

0 comments on commit 6ca3492

Please sign in to comment.