Add run-java script
All checks were successful
moparisthebest/self-ci/pipeline/head This commit looks good

This commit is contained in:
Travis Burtrum 2020-11-20 00:00:46 -05:00
parent ab8ba7fdc1
commit 022e12a487
3 changed files with 68 additions and 15 deletions

View File

@ -22,7 +22,7 @@ RUN mkdir /m2 /npm && ln -sf /m2/ /root/.m2 && ln -sf /npm/ /root/.npm && \
curl https://download.java.net/java/early_access/jdk16/23/GPL/openjdk-16-ea+23_linux-x64_bin.tar.gz | bsdtar -xf - -C /usr/lib/jvm && \ curl https://download.java.net/java/early_access/jdk16/23/GPL/openjdk-16-ea+23_linux-x64_bin.tar.gz | bsdtar -xf - -C /usr/lib/jvm && \
mv /usr/lib/jvm/java-se-9-ri/jdk-9 /usr/lib/jvm/ && rm -rf java-se-9-ri && chmod +x /usr/lib/jvm/jdk-9/bin/* mv /usr/lib/jvm/java-se-9-ri/jdk-9 /usr/lib/jvm/ && rm -rf java-se-9-ri && chmod +x /usr/lib/jvm/jdk-9/bin/*
COPY ./build.sh /usr/bin/ COPY ./build.sh ./run-java /usr/bin/
VOLUME [ "/build", "/m2", "/npm" ] VOLUME [ "/build", "/m2", "/npm" ]

View File

@ -1,19 +1,7 @@
#!/bin/bash #!/bin/bash
set -euo pipefail set -euo pipefail
for jdk in ${BUILD_JDKS:-java-6-jdk java-7-openjdk java-8-openjdk jdk-9 jdk-10 java-11-openjdk jdk-12 jdk-13 java-14-openjdk jdk-15 jdk-16} for jdk in ${BUILD_JDKS:-6 7 8 9 10 11 12 13 14 15 16}
do do
sudo archlinux-java set "$jdk" run-java "$jdk" "$@"
export JAVA_VERSION="$(echo "$jdk" | grep -Eo '[0-9]+')"
export JAVA_HOME="/usr/lib/jvm/$jdk"
export M2_HOME="/opt/maven"
# maven 3.2.5 is the latest version supported by 6
[ $JAVA_VERSION -eq 6 ] && export M2_HOME="/opt/apache-maven-3.2.5"
export PATH="$JAVA_HOME/bin:$M2_HOME/bin:$PATH"
echo "building with JAVA_VERSION='$JAVA_VERSION' JAVA_HOME='$JAVA_HOME'"
"$@"
done done

65
java/run-java Executable file
View File

@ -0,0 +1,65 @@
#!/bin/bash
# first arg can be a numeric version, or a folder in /usr/lib/jvm/
jdk="$1"
shift
JAVA_HOME="/usr/lib/jvm/$jdk"
M2_HOME="/opt/maven"
if [ ! -d "$JAVA_HOME" ]
then
# it's probably a number
JAVA_VERSION="$jdk"
case "$JAVA_VERSION" in
6)
jdk=java-6-jdk
;;
7)
jdk=java-7-openjdk
;;
8)
jdk=java-8-openjdk
;;
9)
jdk=jdk-9
;;
10)
jdk=jdk-10
;;
11)
jdk=java-11-openjdk
;;
12)
jdk=jdk-12
;;
13)
jdk=jdk-13
;;
14)
jdk=java-14-openjdk
;;
15)
jdk=jdk-15
;;
16)
jdk=jdk-16
;;
*)
echo "run-java: unknown jdk: $jdk"
exit 1
;;
esac
JAVA_HOME="/usr/lib/jvm/$jdk"
else
# it's a folder
JAVA_VERSION="$(echo "$jdk" | grep -Eo '[0-9]+')"
fi
# maven 3.2.5 is the latest version supported by 6
[ $JAVA_VERSION -eq 6 ] && export M2_HOME="/opt/apache-maven-3.2.5"
JAVA_VERSION=$JAVA_VERSION M2_HOME="$M2_HOME" JAVA_HOME="$JAVA_HOME" PATH="$JAVA_HOME/bin:$M2_HOME/bin:$PATH" exec "$@"