diff --git a/packages/scala/3.2.2/build.sh b/packages/scala/3.2.2/build.sh new file mode 100644 index 0000000..b40b10e --- /dev/null +++ b/packages/scala/3.2.2/build.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# Download and extract JDK8 +curl -L "https://github.com/AdoptOpenJDK/openjdk16-binaries/releases/download/jdk-16.0.1%2B9_openj9-0.26.0/OpenJDK16U-jdk_x64_linux_openj9_16.0.1_9_openj9-0.26.0.tar.gz" -o jdk.tar.gz +tar xzf jdk.tar.gz --strip-components=1 +rm jdk.tar.gz + +# Download and extract Scala 3 +curl -L "https://github.com/lampepfl/dotty/releases/download/3.2.2/scala3-3.2.2.tar.gz" -o scala.tar.gz +tar -xzf scala.tar.gz --strip-components=1 +rm scala.tar.gz \ No newline at end of file diff --git a/packages/scala/3.2.2/compile b/packages/scala/3.2.2/compile new file mode 100644 index 0000000..5febbdc --- /dev/null +++ b/packages/scala/3.2.2/compile @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +# Compile scala classes into a jar file +scalac "$@" -d out.jar + +# Create the Manifest and include scala lib jars: +# NOTE: - entry point will only consider @main and App traits from the main file +# - scala lib jars will be added to the class path in order to run the jar properly +echo "Main-Class: $(grep -oP '\@main\s+def\s+\K[a-zA-Z][a-zA-Z0-9]*|object\s+\K[a-zA-Z][a-zA-Z0-9]*(?=\s+extends\s+App)' $1) +Class-Path: $(echo $JAVA_HOME/lib/*.jar | sed 's/\s/\n /g') + +" > manifest.txt + +# Update the jar with the manifest +jar ufm out.jar manifest.txt \ No newline at end of file diff --git a/packages/scala/3.2.2/environment b/packages/scala/3.2.2/environment new file mode 100644 index 0000000..588262f --- /dev/null +++ b/packages/scala/3.2.2/environment @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +# Scala requires JAVA_HOME to be set +export JAVA_HOME=$PWD +export PATH=$PWD/bin:$PATH \ No newline at end of file diff --git a/packages/scala/3.2.2/metadata.json b/packages/scala/3.2.2/metadata.json new file mode 100644 index 0000000..545c824 --- /dev/null +++ b/packages/scala/3.2.2/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "scala", + "version": "3.2.2", + "aliases": ["sc"] +} \ No newline at end of file diff --git a/packages/scala/3.2.2/run b/packages/scala/3.2.2/run new file mode 100644 index 0000000..accfd16 --- /dev/null +++ b/packages/scala/3.2.2/run @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +# Run jar file +shift +java -jar out.jar "$@" \ No newline at end of file diff --git a/packages/scala/3.2.2/test.scala b/packages/scala/3.2.2/test.scala new file mode 100644 index 0000000..bf4cabc --- /dev/null +++ b/packages/scala/3.2.2/test.scala @@ -0,0 +1,3 @@ +@main def run(): Unit = { + println("OK") +} \ No newline at end of file