Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helper to get extension bom in devtools #18966

Merged
merged 1 commit into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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