From c79ef2b4e488ec38d95a0f1a7976389e86fb211d Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Fri, 13 Oct 2023 10:29:35 +0200 Subject: [PATCH 1/3] Upgrade to JUnit Platform `1.10.0`. Fixes #492. --- gradle/libs.versions.toml | 2 +- samples/java-application-with-custom-tests/gradle.properties | 2 +- samples/java-application-with-extra-sourceset/gradle.properties | 2 +- samples/java-application-with-reflection/gradle.properties | 2 +- samples/java-application-with-resources/gradle.properties | 2 +- samples/java-application-with-tests/gradle.properties | 2 +- samples/java-application/gradle.properties | 2 +- samples/java-library/gradle.properties | 2 +- samples/kotlin-application-with-tests/gradle.properties | 2 +- samples/multi-project-with-tests/gradle.properties | 2 +- samples/native-config-integration/gradle.properties | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 654219a94..aa5fdc305 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,7 +11,7 @@ mavenEmbedder = "3.8.6" mavenWagon = "3.4.3" graalvm = "22.3.3" jackson = "2.13.5" -junitPlatform = "1.9.3" +junitPlatform = "1.10.0" junitJupiter = "5.10.0" aether = "1.1.0" slf4j = "1.7.9" diff --git a/samples/java-application-with-custom-tests/gradle.properties b/samples/java-application-with-custom-tests/gradle.properties index 489d10930..bdc0d568d 100644 --- a/samples/java-application-with-custom-tests/gradle.properties +++ b/samples/java-application-with-custom-tests/gradle.properties @@ -1,3 +1,3 @@ native.gradle.plugin.version = 0.9.28-SNAPSHOT junit.jupiter.version = 5.10.0 -junit.platform.version = 1.9.3 +junit.platform.version = 1.10.0 diff --git a/samples/java-application-with-extra-sourceset/gradle.properties b/samples/java-application-with-extra-sourceset/gradle.properties index 489d10930..bdc0d568d 100644 --- a/samples/java-application-with-extra-sourceset/gradle.properties +++ b/samples/java-application-with-extra-sourceset/gradle.properties @@ -1,3 +1,3 @@ native.gradle.plugin.version = 0.9.28-SNAPSHOT junit.jupiter.version = 5.10.0 -junit.platform.version = 1.9.3 +junit.platform.version = 1.10.0 diff --git a/samples/java-application-with-reflection/gradle.properties b/samples/java-application-with-reflection/gradle.properties index 489d10930..bdc0d568d 100644 --- a/samples/java-application-with-reflection/gradle.properties +++ b/samples/java-application-with-reflection/gradle.properties @@ -1,3 +1,3 @@ native.gradle.plugin.version = 0.9.28-SNAPSHOT junit.jupiter.version = 5.10.0 -junit.platform.version = 1.9.3 +junit.platform.version = 1.10.0 diff --git a/samples/java-application-with-resources/gradle.properties b/samples/java-application-with-resources/gradle.properties index 489d10930..bdc0d568d 100644 --- a/samples/java-application-with-resources/gradle.properties +++ b/samples/java-application-with-resources/gradle.properties @@ -1,3 +1,3 @@ native.gradle.plugin.version = 0.9.28-SNAPSHOT junit.jupiter.version = 5.10.0 -junit.platform.version = 1.9.3 +junit.platform.version = 1.10.0 diff --git a/samples/java-application-with-tests/gradle.properties b/samples/java-application-with-tests/gradle.properties index 489d10930..bdc0d568d 100644 --- a/samples/java-application-with-tests/gradle.properties +++ b/samples/java-application-with-tests/gradle.properties @@ -1,3 +1,3 @@ native.gradle.plugin.version = 0.9.28-SNAPSHOT junit.jupiter.version = 5.10.0 -junit.platform.version = 1.9.3 +junit.platform.version = 1.10.0 diff --git a/samples/java-application/gradle.properties b/samples/java-application/gradle.properties index 489d10930..bdc0d568d 100644 --- a/samples/java-application/gradle.properties +++ b/samples/java-application/gradle.properties @@ -1,3 +1,3 @@ native.gradle.plugin.version = 0.9.28-SNAPSHOT junit.jupiter.version = 5.10.0 -junit.platform.version = 1.9.3 +junit.platform.version = 1.10.0 diff --git a/samples/java-library/gradle.properties b/samples/java-library/gradle.properties index 489d10930..bdc0d568d 100644 --- a/samples/java-library/gradle.properties +++ b/samples/java-library/gradle.properties @@ -1,3 +1,3 @@ native.gradle.plugin.version = 0.9.28-SNAPSHOT junit.jupiter.version = 5.10.0 -junit.platform.version = 1.9.3 +junit.platform.version = 1.10.0 diff --git a/samples/kotlin-application-with-tests/gradle.properties b/samples/kotlin-application-with-tests/gradle.properties index 489d10930..bdc0d568d 100644 --- a/samples/kotlin-application-with-tests/gradle.properties +++ b/samples/kotlin-application-with-tests/gradle.properties @@ -1,3 +1,3 @@ native.gradle.plugin.version = 0.9.28-SNAPSHOT junit.jupiter.version = 5.10.0 -junit.platform.version = 1.9.3 +junit.platform.version = 1.10.0 diff --git a/samples/multi-project-with-tests/gradle.properties b/samples/multi-project-with-tests/gradle.properties index 489d10930..bdc0d568d 100644 --- a/samples/multi-project-with-tests/gradle.properties +++ b/samples/multi-project-with-tests/gradle.properties @@ -1,3 +1,3 @@ native.gradle.plugin.version = 0.9.28-SNAPSHOT junit.jupiter.version = 5.10.0 -junit.platform.version = 1.9.3 +junit.platform.version = 1.10.0 diff --git a/samples/native-config-integration/gradle.properties b/samples/native-config-integration/gradle.properties index 489d10930..bdc0d568d 100644 --- a/samples/native-config-integration/gradle.properties +++ b/samples/native-config-integration/gradle.properties @@ -1,3 +1,3 @@ native.gradle.plugin.version = 0.9.28-SNAPSHOT junit.jupiter.version = 5.10.0 -junit.platform.version = 1.9.3 +junit.platform.version = 1.10.0 From d96da570f41d0c37d44c5bc499e36d6ca753036e Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Fri, 13 Oct 2023 13:14:49 +0200 Subject: [PATCH 2/3] Fix and improve major JDK version detection. Fixes #516 --- .../buildtools/utils/NativeImageUtils.java | 13 ++++++-- .../utils/NativeImageUtilsTest.java | 32 +++++++++++++++++-- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/common/utils/src/main/java/org/graalvm/buildtools/utils/NativeImageUtils.java b/common/utils/src/main/java/org/graalvm/buildtools/utils/NativeImageUtils.java index e3f0d9f36..71d235e25 100644 --- a/common/utils/src/main/java/org/graalvm/buildtools/utils/NativeImageUtils.java +++ b/common/utils/src/main/java/org/graalvm/buildtools/utils/NativeImageUtils.java @@ -61,6 +61,10 @@ public class NativeImageUtils { private static final Pattern graalvmVersionPattern = Pattern.compile("^(GraalVM|native-image) ([0-9]+)\\.([0-9]+)\\.([0-9]+).*"); + private static final Pattern javaVersionPattern = Pattern.compile("^native-image ([0-9]+).*", Pattern.DOTALL); + private static final Pattern javaVersionLegacyPattern = Pattern.compile(".* \\(Java Version ([0-9]+)\\.([0-9]+)\\.([0-9]+).*"); + + private static final Pattern SAFE_SHELL_ARG = Pattern.compile("[A-Za-z0-9@%_\\-+=:,./]+"); public static void maybeCreateConfigureUtilSymlink(File configureUtilFile, Path nativeImageExecutablePath) { @@ -170,9 +174,14 @@ public static void checkVersion(String requiredVersion, String versionToCheck) { } public static int getMajorJDKVersion(String versionString) { - Matcher matcher = graalvmVersionPattern.matcher(versionString.trim()); + String trimmedVersionString = versionString.trim(); + Matcher matcher = javaVersionPattern.matcher(versionString.trim()); if (matcher.matches()) { - return Integer.parseInt(matcher.group(2)); + return Integer.parseInt(matcher.group(1)); + } + Matcher legacyMatcher = javaVersionLegacyPattern.matcher(trimmedVersionString); + if (legacyMatcher.matches()) { + return Integer.parseInt(legacyMatcher.group(1)); } return -1; } diff --git a/common/utils/src/test/java/org/graalvm/buildtools/utils/NativeImageUtilsTest.java b/common/utils/src/test/java/org/graalvm/buildtools/utils/NativeImageUtilsTest.java index 92bc3cdfb..5d775ae8d 100644 --- a/common/utils/src/test/java/org/graalvm/buildtools/utils/NativeImageUtilsTest.java +++ b/common/utils/src/test/java/org/graalvm/buildtools/utils/NativeImageUtilsTest.java @@ -65,21 +65,33 @@ void invalidRequiredVersion() { @Test void checkGraalVMCEVersion() { - NativeImageUtils.checkVersion("22", "GraalVM 22.3.0 Java 17 CE (Java Version 17.0.5+8-jvmci-22.3-b08)"); - NativeImageUtils.checkVersion("22.3", "GraalVM 22.3.0 Java 17 CE (Java Version 17.0.5+8-jvmci-22.3-b08)"); - NativeImageUtils.checkVersion("22.3.0", "GraalVM 22.3.0 Java 17 CE (Java Version 17.0.5+8-jvmci-22.3-b08)"); + String graalVMCE_22_3 = "GraalVM 22.3.0 Java 17 CE (Java Version 17.0.5+8-jvmci-22.3-b08)"; + NativeImageUtils.checkVersion("22", graalVMCE_22_3); + NativeImageUtils.checkVersion("22.3", graalVMCE_22_3); + NativeImageUtils.checkVersion("22.3.0", graalVMCE_22_3); + Assertions.assertEquals(17, NativeImageUtils.getMajorJDKVersion(graalVMCE_22_3)); String graalVMCEForJDK17 = "native-image 17.0.7 2023-04-18\nGraalVM Runtime Environment GraalVM CE 17.0.7+4.1 (build 17.0.7+4-jvmci-23.0-b10)\nSubstrate VM GraalVM CE 17.0.7+4.1 (build 17.0.7+4, serial gc)"; NativeImageUtils.checkVersion("22.3.0", graalVMCEForJDK17); NativeImageUtils.checkVersion("23", graalVMCEForJDK17); NativeImageUtils.checkVersion("23.0", graalVMCEForJDK17); NativeImageUtils.checkVersion("23.0.0", graalVMCEForJDK17); + Assertions.assertEquals(17, NativeImageUtils.getMajorJDKVersion(graalVMCEForJDK17)); String graalVMCEForJDK20 = "native-image 20 2023-04-18\nGraalVM Runtime Environment GraalVM CE 20+34.1 (build 20+34-jvmci-23.0-b10)\nSubstrate VM GraalVM CE 20+34.1 (build 20+34, serial gc)"; NativeImageUtils.checkVersion("22.3.0", graalVMCEForJDK20); NativeImageUtils.checkVersion("23", graalVMCEForJDK20); NativeImageUtils.checkVersion("23.0", graalVMCEForJDK20); NativeImageUtils.checkVersion("23.0.0", graalVMCEForJDK20); + Assertions.assertEquals(20, NativeImageUtils.getMajorJDKVersion(graalVMCEForJDK20)); + + String graalVMCEForJDK21 = "native-image 21 2023-09-19\nGraalVM Runtime Environment GraalVM CE 21+35.1 (build 21+35-jvmci-23.1-b15)\nSubstrate VM GraalVM CE 21+35.1 (build 21+35, serial gc)"; + NativeImageUtils.checkVersion("22.3.0", graalVMCEForJDK20); + NativeImageUtils.checkVersion("23", graalVMCEForJDK20); + NativeImageUtils.checkVersion("23.0", graalVMCEForJDK20); + NativeImageUtils.checkVersion("23.1", graalVMCEForJDK20); + NativeImageUtils.checkVersion("23.1.0", graalVMCEForJDK20); + Assertions.assertEquals(21, NativeImageUtils.getMajorJDKVersion(graalVMCEForJDK21)); } @Test @@ -90,6 +102,8 @@ void checkGraalVMCEDevVersion() { NativeImageUtils.checkVersion("22.3.0", "GraalVM 23.0.0-dev Java 17.0.6+2-jvmci-23.0-b04 CE (Java Version 17.0.6+2-jvmci-23.0-b04)"); NativeImageUtils.checkVersion("22.3.0", "GraalVM dev CE (Java Version 19+36-jvmci-23.0-b01)"); NativeImageUtils.checkVersion("22.3.0", "native-image dev CE (Java Version 19+36-jvmci-23.0-b01)"); + String latestGraalVMDevFormat = "native-image 21 2023-09-19\nGraalVM Runtime Environment GraalVM CE 21-dev+35.1 (build 21+35-jvmci-23.1-b15)\nSubstrate VM GraalVM CE 21-dev+35.1 (build 21+35, serial gc)"; + NativeImageUtils.checkVersion("22.3.0", latestGraalVMDevFormat); } @Test @@ -97,18 +111,30 @@ void checkGraalVMEEVersion() { NativeImageUtils.checkVersion("22", "GraalVM 22.3.0 Java 17 EE (Java Version 17.0.5+9-LTS-jvmci-22.3-b07)"); NativeImageUtils.checkVersion("22.3", "GraalVM 22.3.0 Java 17 EE (Java Version 17.0.5+9-LTS-jvmci-22.3-b07)"); NativeImageUtils.checkVersion("22.3.0", "GraalVM 22.3.0 Java 17 EE (Java Version 17.0.5+9-LTS-jvmci-22.3-b07)"); + } + @Test + void checkOracleGraalVMVersion() { String oracleGraalVMForJDK17 = "native-image 17.0.7 2023-04-18\nGraalVM Runtime Environment Oracle GraalVM (build 17.0.7+8-jvmci-23.0-b10)\nSubstrate VM Oracle GraalVM (build 17.0.7+8, serial gc)"; NativeImageUtils.checkVersion("22.3.0", oracleGraalVMForJDK17); NativeImageUtils.checkVersion("23", oracleGraalVMForJDK17); NativeImageUtils.checkVersion("23.0", oracleGraalVMForJDK17); NativeImageUtils.checkVersion("23.0.0", oracleGraalVMForJDK17); + Assertions.assertEquals(17, NativeImageUtils.getMajorJDKVersion(oracleGraalVMForJDK17)); String oracleGraalVMForJDK20 = "native-image 20.0.1 2023-04-18\nGraalVM Runtime Environment Oracle GraalVM 20.0.1+9.1 (build 20.0.1+9-jvmci-23.0-b10)\nSubstrate VM Oracle GraalVM 20.0.1+9.1 (build 20.0.1+9, serial gc)"; NativeImageUtils.checkVersion("22.3.0", oracleGraalVMForJDK20); NativeImageUtils.checkVersion("23", oracleGraalVMForJDK20); NativeImageUtils.checkVersion("23.0", oracleGraalVMForJDK20); NativeImageUtils.checkVersion("23.0.0", oracleGraalVMForJDK20); + Assertions.assertEquals(20, NativeImageUtils.getMajorJDKVersion(oracleGraalVMForJDK20)); + + String oracleGraalVMForJDK21 = "native-image 21 2023-09-19\nGraalVM Runtime Environment Oracle GraalVM 21+35.1 (build 21+35-jvmci-23.1-b15)\nSubstrate VM Oracle GraalVM 21+35.1 (build 21+35, serial gc, compressed references)"; + NativeImageUtils.checkVersion("22.3.0", oracleGraalVMForJDK21); + NativeImageUtils.checkVersion("23", oracleGraalVMForJDK21); + NativeImageUtils.checkVersion("23.1", oracleGraalVMForJDK21); + NativeImageUtils.checkVersion("23.1.0", oracleGraalVMForJDK21); + Assertions.assertEquals(21, NativeImageUtils.getMajorJDKVersion(oracleGraalVMForJDK21)); } @Test From e45d67531ecc486aa158c853b4050ca55b542335 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Fri, 13 Oct 2023 13:34:46 +0200 Subject: [PATCH 3/3] Add changelog entry and fix changelog. [ci skip] --- docs/src/docs/asciidoc/index.adoc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/src/docs/asciidoc/index.adoc b/docs/src/docs/asciidoc/index.adoc index f32e4ca31..fd18357a1 100644 --- a/docs/src/docs/asciidoc/index.adoc +++ b/docs/src/docs/asciidoc/index.adoc @@ -19,15 +19,19 @@ If you are using alternative build systems, see <