From ca99ee5203f8abfee9701c78dfc5eb7fa6371f27 Mon Sep 17 00:00:00 2001
From: Raphael Parree <rparree@edc4it.com>
Date: Tue, 27 Aug 2024 09:27:00 +0200
Subject: [PATCH] Scala 3.5.0 (#299)

---
 .github/workflows/build.yml       | 17 ++++++++++++++++-
 eclipse-temurin/Dockerfile        |  8 +++++---
 eclipse-temurin/alpine.Dockerfile |  4 ++--
 graalvm-ce/Dockerfile             |  2 +-
 graalvm-community/Dockerfile      |  2 +-
 5 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 9dcfce1..fa2f15f 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -16,7 +16,7 @@ jobs:
     runs-on: ubuntu-latest
     strategy:
       matrix:
-        scalaVersion: ['2.12.19', '2.13.14', '3.3.3', '3.4.3']
+        scalaVersion: ['2.12.19', '2.13.14', '3.4.3', '3.5.0']
         javaTag: [
           'graalvm-community-22.0.1',
           'graalvm-community-21.0.2',
@@ -72,6 +72,21 @@ jobs:
             dockerfile: 'alpine.Dockerfile'
             baseImageTag: '17.0.10_7-jdk-alpine'
             platforms: 'linux/amd64'
+        exclude:
+          # https://github.com/VirtusLab/scala-cli/issues/3130
+          - scalaVersion: '3.5.0'
+            javaTag: 'graalvm-community-22.0.1'
+          - scalaVersion: '3.5.0'
+            javaTag: 'graalvm-community-21.0.2'
+          - scalaVersion: '3.5.0'
+            javaTag: 'graalvm-ce-22.3.3-b1-java17'
+          # https://github.com/VirtusLab/scala-cli/issues/2758
+          # - scalaVersion: '3.5.0'
+          #   javaTag: 'eclipse-temurin-alpine-22_36'
+          # - scalaVersion: '3.5.0'
+          #   javaTag: 'eclipse-temurin-alpine-21.0.2_13'
+          # - scalaVersion: '3.5.0'
+          #   javaTag: 'eclipse-temurin-alpine-17.0.10_7'
     steps:
     - uses: actions/checkout@v4
     - name: Set up QEMU
diff --git a/eclipse-temurin/Dockerfile b/eclipse-temurin/Dockerfile
index db5aef9..8310b5e 100644
--- a/eclipse-temurin/Dockerfile
+++ b/eclipse-temurin/Dockerfile
@@ -44,11 +44,13 @@ RUN \
   chown -R root:root /usr/share/scala && \
   chmod -R 755 /usr/share/scala && \
   ln -s /usr/share/scala/bin/* /usr/local/bin && \
+  mkdir -p /test && \
   case $SCALA_VERSION in \
-    "3"*) echo '@main def main = println(s"Scala library version ${dotty.tools.dotc.config.Properties.versionNumberString}")' > test.scala ;; \
-    *) echo "println(util.Properties.versionMsg)" > test.scala ;; \
+    "3"*) echo 'import java.io.FileInputStream;import java.util.jar.JarInputStream;val scala3LibJar = classOf[CanEqual[_, _]].getProtectionDomain.getCodeSource.getLocation.toURI.getPath;val manifest = new JarInputStream(new FileInputStream(scala3LibJar)).getManifest;val ver = manifest.getMainAttributes.getValue("Implementation-Version");@main def main = println(s"Scala version ${ver}")' > /test/test.scala ;; \
+    *) echo "println(util.Properties.versionMsg)" > /test/test.scala ;; \
   esac && \
-  scala -nocompdaemon test.scala && rm test.scala
+  scala -nocompdaemon test/test.scala && \
+  rm -fr test
 
 # Symlink java to have it available on sbtuser's PATH
 RUN ln -s /opt/java/openjdk/bin/java /usr/local/bin/java
diff --git a/eclipse-temurin/alpine.Dockerfile b/eclipse-temurin/alpine.Dockerfile
index 7990c78..dfaa70d 100644
--- a/eclipse-temurin/alpine.Dockerfile
+++ b/eclipse-temurin/alpine.Dockerfile
@@ -24,8 +24,8 @@ RUN \
     update-ca-certificates && \
     scala -version && \
     case $SCALA_VERSION in \
-      "3"*) echo '@main def main = println(s"Scala library version ${dotty.tools.dotc.config.Properties.versionNumberString}")' > test.scala ;; \
-      *) echo "println(util.Properties.versionMsg)" > test.scala ;; \
+    "3"*) echo 'import java.io.FileInputStream;import java.util.jar.JarInputStream;val scala3LibJar = classOf[CanEqual[_, _]].getProtectionDomain.getCodeSource.getLocation.toURI.getPath;val manifest = new JarInputStream(new FileInputStream(scala3LibJar)).getManifest;val ver = manifest.getMainAttributes.getValue("Implementation-Version");@main def main = println(s"Scala version ${ver}")' > test.scala ;; \
+    *) echo "println(util.Properties.versionMsg)" > test.scala ;; \
     esac && \
     scala -nocompdaemon test.scala && rm test.scala
 
diff --git a/graalvm-ce/Dockerfile b/graalvm-ce/Dockerfile
index 20015d5..f2070f1 100644
--- a/graalvm-ce/Dockerfile
+++ b/graalvm-ce/Dockerfile
@@ -39,7 +39,7 @@ RUN \
   chmod -R 755 /usr/share/scala && \
   ln -s /usr/share/scala/bin/* /usr/local/bin && \
   case $SCALA_VERSION in \
-    "3"*) echo '@main def main = println(s"Scala library version ${dotty.tools.dotc.config.Properties.versionNumberString}")' > test.scala ;; \
+    "3"*) echo 'import java.io.FileInputStream;import java.util.jar.JarInputStream;val scala3LibJar = classOf[CanEqual[_, _]].getProtectionDomain.getCodeSource.getLocation.toURI.getPath;val manifest = new JarInputStream(new FileInputStream(scala3LibJar)).getManifest;val ver = manifest.getMainAttributes.getValue("Implementation-Version");@main def main = println(s"Scala version ${ver}")' > test.scala ;; \
     *) echo "println(util.Properties.versionMsg)" > test.scala ;; \
   esac && \
   scala -nocompdaemon test.scala && rm test.scala
diff --git a/graalvm-community/Dockerfile b/graalvm-community/Dockerfile
index 6cf27df..130fb3f 100644
--- a/graalvm-community/Dockerfile
+++ b/graalvm-community/Dockerfile
@@ -39,7 +39,7 @@ RUN \
   chmod -R 755 /usr/share/scala && \
   ln -s /usr/share/scala/bin/* /usr/local/bin && \
   case $SCALA_VERSION in \
-    "3"*) echo '@main def main = println(s"Scala library version ${dotty.tools.dotc.config.Properties.versionNumberString}")' > test.scala ;; \
+    "3"*) echo 'import java.io.FileInputStream;import java.util.jar.JarInputStream;val scala3LibJar = classOf[CanEqual[_, _]].getProtectionDomain.getCodeSource.getLocation.toURI.getPath;val manifest = new JarInputStream(new FileInputStream(scala3LibJar)).getManifest;val ver = manifest.getMainAttributes.getValue("Implementation-Version");@main def main = println(s"Scala version ${ver}")' > test.scala ;; \
     *) echo "println(util.Properties.versionMsg)" > test.scala ;; \
   esac && \
   scala -nocompdaemon test.scala && rm test.scala