Skip to content

Commit

Permalink
Merge pull request #45542 from rsvoboda/isJava11OrHigher
Browse files Browse the repository at this point in the history
Check for Java 17 as a base, remove isJava11OrHigher method
  • Loading branch information
gsmet authored Jan 13, 2025
2 parents b870c90 + d59e1ac commit 86ff381
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public class QuarkusAugmentor {
}

public BuildResult run() throws Exception {
if (!JavaVersionUtil.isJava11OrHigher()) {
throw new IllegalStateException("Quarkus applications require Java 11 or higher to build");
if (!JavaVersionUtil.isJava17OrHigher()) {
throw new IllegalStateException("Quarkus applications require Java 17 or higher to build");
}
long start = System.nanoTime();
log.debug("Beginning Quarkus augmentation");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ public class JavaVersionUtil {

private static final Pattern PATTERN = Pattern.compile("(?:1\\.)?(\\d+)");

private static boolean IS_JAVA_11_OR_NEWER;
private static boolean IS_JAVA_13_OR_NEWER;
private static boolean IS_GRAALVM_JDK;
private static boolean IS_JAVA_16_OR_OLDER;
Expand All @@ -24,14 +23,12 @@ static void performChecks() {
Matcher matcher = PATTERN.matcher(System.getProperty("java.specification.version", ""));
if (matcher.matches()) {
int first = Integer.parseInt(matcher.group(1));
IS_JAVA_11_OR_NEWER = (first >= 11);
IS_JAVA_13_OR_NEWER = (first >= 13);
IS_JAVA_16_OR_OLDER = (first <= 16);
IS_JAVA_17_OR_NEWER = (first >= 17);
IS_JAVA_19_OR_NEWER = (first >= 19);
IS_JAVA_21_OR_NEWER = (first >= 21);
} else {
IS_JAVA_11_OR_NEWER = false;
IS_JAVA_13_OR_NEWER = false;
IS_JAVA_16_OR_OLDER = false;
IS_JAVA_17_OR_NEWER = false;
Expand All @@ -43,10 +40,6 @@ static void performChecks() {
IS_GRAALVM_JDK = (vmVendor != null) && vmVendor.startsWith("GraalVM");
}

public static boolean isJava11OrHigher() {
return IS_JAVA_11_OR_NEWER;
}

public static boolean isJava13OrHigher() {
return IS_JAVA_13_OR_NEWER;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,38 @@ class JavaVersionUtilTest {
@Test
void testJava8() {
testWithVersion("1.8", () -> {
assertFalse(JavaVersionUtil.isJava11OrHigher());
assertFalse(JavaVersionUtil.isJava13OrHigher());
});
}

@Test
void testJava11() {
testWithVersion("11", () -> {
assertTrue(JavaVersionUtil.isJava11OrHigher());
assertFalse(JavaVersionUtil.isJava13OrHigher());
});
}

@Test
void testJava14() {
testWithVersion("14", () -> {
assertTrue(JavaVersionUtil.isJava11OrHigher());
assertTrue(JavaVersionUtil.isJava13OrHigher());
});
}

@Test
void testJava17() {
testWithVersion("17", () -> {
assertTrue(JavaVersionUtil.isJava11OrHigher());
assertTrue(JavaVersionUtil.isJava13OrHigher());
assertTrue(JavaVersionUtil.isJava17OrHigher());
assertFalse(JavaVersionUtil.isJava21OrHigher());
});
}

@Test
void testJava21() {
testWithVersion("21", () -> {
assertTrue(JavaVersionUtil.isJava11OrHigher());
assertTrue(JavaVersionUtil.isJava13OrHigher());
assertTrue(JavaVersionUtil.isJava21OrHigher());
});
}

Expand Down

0 comments on commit 86ff381

Please sign in to comment.