Skip to content

Commit

Permalink
Allow to retrieve minimum and recommended Java versions from catalog …
Browse files Browse the repository at this point in the history
…metadata
  • Loading branch information
ia3andy committed Nov 21, 2023
1 parent e56b8ec commit 808fba7
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,12 @@ public List<ProcessedCategory> getProcessedCategoriesInOrder() {
public static MetadataValue getMetadataValue(ExtensionCatalog catalog, String path) {
return MetadataValue.get(catalog.getMetadata(), path);
}

public static String getMinimumJavaVersion(ExtensionCatalog catalog) {
return getMetadataValue(catalog, ExtensionCatalog.MD_MINIMUM_JAVA_VERSION).asString();
}

public static String getRecommendedJavaVersion(ExtensionCatalog catalog) {
return getMetadataValue(catalog, ExtensionCatalog.MD_RECOMMENDED_JAVA_VERSION).asString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.Locale;
import java.util.Map;

final class MetadataValue {
public final class MetadataValue {
private static final MetadataValue EMPTY_METADATA_VALUE = new MetadataValue(null);
private final Object val;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@
"gradle-plugin-id": "io.quarkus",
"gradle-plugin-version": "999-FAKE",
"supported-maven-versions": "[3.6.2,)",
"minimum-java-version": "11",
"recommended-java-version": "17",
"proposed-maven-version": "3.9.5",
"maven-wrapper-version": "3.2.0",
"gradle-wrapper-version": "8.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

public interface ExtensionCatalog extends ExtensionOrigin {

String MD_MINIMUM_JAVA_VERSION = "project.properties.minimum-java-version";
String MD_RECOMMENDED_JAVA_VERSION = "project.properties.recommended-java-version";

/**
* All the origins this catalog is derived from.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package io.quarkus.platform.catalog;

import static io.quarkus.devtools.testing.FakeExtensionCatalog.newFakeExtensionCatalog;
import static io.quarkus.platform.catalog.processor.CatalogProcessor.getMinimumJavaVersion;
import static io.quarkus.platform.catalog.processor.CatalogProcessor.getProcessedCategoriesInOrder;
import static io.quarkus.platform.catalog.processor.CatalogProcessor.getRecommendedJavaVersion;
import static org.assertj.core.api.Assertions.assertThat;

import java.util.Objects;
Expand All @@ -27,6 +29,13 @@ void testCategoryOrder() {
.startsWith("web", "core", "reactive", "serialization", "compatibility", "alt-languages", "uncategorized");
}

@Test
void testJavaVersions() {
final ExtensionCatalog catalog = newFakeExtensionCatalog();
assertThat(getMinimumJavaVersion(catalog)).isEqualTo("11");
assertThat(getRecommendedJavaVersion(catalog)).isEqualTo("17");
}

@Test
void testExtensionsOrder() {
final ExtensionCatalog catalog = newFakeExtensionCatalog();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
"supported-maven-versions": "${supported-maven-versions}",
"proposed-maven-version": "${proposed-maven-version}",
"maven-wrapper-version": "${maven-wrapper.version}",
"gradle-wrapper-version": "${gradle-wrapper.version}"
"gradle-wrapper-version": "${gradle-wrapper.version}",
"minimum-java-version": "${minimum-java-version}",
"recommended-java-version": "${recommended-java-version}"
}
},
"codestarts-artifacts": [
Expand Down

0 comments on commit 808fba7

Please sign in to comment.