diff --git a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/GraalVM.java b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/GraalVM.java index 1b212a0369006..b581c38415e98 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/GraalVM.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/GraalVM.java @@ -18,6 +18,8 @@ static final class VersionParseHelper { private static final String JVMCI_BUILD_PREFIX = "jvmci-"; private static final String MANDREL_VERS_PREFIX = "Mandrel-"; + private static final String LIBERICA_NIK_VERS_PREFIX = "Liberica-NIK-"; + // Java version info (suitable for Runtime.Version.parse()). See java.lang.VersionProps private static final String VNUM = "(?[1-9][0-9]*(?:(?:\\.0)*\\.[1-9][0-9]*)*)"; private static final String PRE = "(?:-(?
[a-zA-Z0-9]+))?";
@@ -68,19 +70,47 @@ static Version parse(List lines) {
                 if (vendorVersion.contains("-dev")) {
                     graalVersion = graalVersion + "-dev";
                 }
-                String mandrelVersion = mandrelVersion(vendorVersion);
-                Distribution dist = isMandrel(vendorVersion) ? Distribution.MANDREL : Distribution.GRAALVM;
-                String versNum = (dist == Distribution.MANDREL ? mandrelVersion : graalVersion);
+                String versNum;
+                Distribution dist;
+                if (isMandrel(vendorVersion)) {
+                    dist = Distribution.MANDREL;
+                    versNum = mandrelVersion(vendorVersion);
+                } else if (isLiberica(vendorVersion)) {
+                    dist = Distribution.LIBERICA;
+                    versNum = libericaVersion(vendorVersion);
+                } else {
+                    dist = Distribution.GRAALVM;
+                    versNum = graalVersion;
+                }
                 if (versNum == null) {
                     return UNKNOWN_VERSION;
                 }
-                return new Version(lines.stream().collect(Collectors.joining("\n")),
+                return new Version(String.join("\n", lines),
                         versNum, v, dist);
             } else {
                 return UNKNOWN_VERSION;
             }
         }
 
+        private static boolean isLiberica(String vendorVersion) {
+            if (vendorVersion == null) {
+                return false;
+            }
+            return !vendorVersion.isBlank() && vendorVersion.startsWith(LIBERICA_NIK_VERS_PREFIX);
+        }
+
+        private static String libericaVersion(String vendorVersion) {
+            if (vendorVersion == null) {
+                return null;
+            }
+            int idx = vendorVersion.indexOf(LIBERICA_NIK_VERS_PREFIX);
+            if (idx < 0) {
+                return null;
+            }
+            String version = vendorVersion.substring(idx + LIBERICA_NIK_VERS_PREFIX.length());
+            return matchVersion(version);
+        }
+
         private static boolean isMandrel(String vendorVersion) {
             if (vendorVersion == null) {
                 return false;
@@ -244,7 +274,7 @@ public static Version of(Stream output) {
             String stringOutput = output.collect(Collectors.joining("\n"));
             List lines = stringOutput.lines()
                     .dropWhile(l -> !l.startsWith("GraalVM") && !l.startsWith("native-image"))
-                    .collect(Collectors.toUnmodifiableList());
+                    .toList();
 
             if (lines.size() == 3) {
                 // Attempt to parse the new 3-line version scheme first.
@@ -322,6 +352,7 @@ public boolean isJava17() {
 
     enum Distribution {
         GRAALVM,
+        LIBERICA,
         MANDREL;
     }
 }
diff --git a/core/deployment/src/test/java/io/quarkus/deployment/pkg/steps/GraalVMTest.java b/core/deployment/src/test/java/io/quarkus/deployment/pkg/steps/GraalVMTest.java
index 2914dfe0ee7cb..9af2755056560 100644
--- a/core/deployment/src/test/java/io/quarkus/deployment/pkg/steps/GraalVMTest.java
+++ b/core/deployment/src/test/java/io/quarkus/deployment/pkg/steps/GraalVMTest.java
@@ -104,6 +104,18 @@ static void assertVersion(Version graalVmVersion, Distribution distro, Version v
         }
     }
 
+    @Test
+    public void testGraalVM21LibericaVersionParser() {
+        Version graalVM21Dev = Version.of(Stream.of(("native-image 21.0.1 2023-10-17\n"
+                + "GraalVM Runtime Environment Liberica-NIK-23.1.1-1 (build 21.0.1+12-LTS)\n"
+                + "Substrate VM Liberica-NIK-23.1.1-1 (build 21.0.1+12-LTS, serial gc)").split("\\n")));
+        assertThat(graalVM21Dev.distribution.name()).isEqualTo("LIBERICA");
+        assertThat(graalVM21Dev.getVersionAsString()).isEqualTo("23.1.1");
+        assertThat(graalVM21Dev.javaVersion.toString()).isEqualTo("21.0.1+12-LTS");
+        assertThat(graalVM21Dev.javaVersion.feature()).isEqualTo(21);
+        assertThat(graalVM21Dev.javaVersion.update()).isEqualTo(1);
+    }
+
     @Test
     public void testGraalVM21VersionParser() {
         Version graalVM21Dev = Version.of(Stream.of(("native-image 21 2023-09-19\n"