Skip to content

Commit

Permalink
Install Java 21 and 22 (closes #276)
Browse files Browse the repository at this point in the history
  • Loading branch information
keeganwitt committed Apr 4, 2024
1 parent 43017e2 commit 8e92ea8
Show file tree
Hide file tree
Showing 8 changed files with 342 additions and 17 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- jdk21
- jdk21-alpine
- jdk21-graal
- jdk21and22
- jdk21and22-alpine
- jdk21and22-graal
steps:
- name: checkout
uses: actions/checkout@v2
Expand All @@ -37,17 +40,19 @@ jobs:
version: ${{ matrix.version }}
run: |
cd "${version}"
baseImage=$(grep "FROM " Dockerfile | cut -d' ' -f2)
docker pull "${baseImage}"
grep "FROM " Dockerfile | cut -d' ' -f2 | xargs -I{} docker pull {}
docker build --tag "gradle:${version}" .
- name: test
env:
version: ${{ matrix.version }}
expectedGradleVersion: "8.7"
run: |
toolchainJavaVersion=$(echo "${version}" | grep --extended-regex --only-matching '[0-9]+' | tail --lines -1)
if [[ "${version}" =~ "graal" ]]; then
cd test-graal
sed --regexp-extended --in-place "s/JavaLanguageVersion\.of\([0-9]+\)/JavaLanguageVersion.of(${toolchainJavaVersion})/" app/build.gradle
else
cd test
sed --regexp-extended --in-place "s/JavaLanguageVersion\.of\([0-9]+\)/JavaLanguageVersion.of(${toolchainJavaVersion})/" lib/build.gradle.kts
fi
./run.sh "gradle:${version}" "${expectedGradleVersion}"
67 changes: 67 additions & 0 deletions jdk21and22-alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
FROM eclipse-temurin:22-jdk-alpine AS java22

FROM eclipse-temurin:21-jdk-alpine

COPY --from=java22 /opt/java/openjdk /opt/java/openjdk22
ENV JAVA21_HOME /opt/java/openjdk21
ENV JAVA22_HOME /opt/java/openjdk22

CMD ["gradle"]

ENV GRADLE_HOME /opt/gradle

RUN set -o errexit -o nounset \
&& echo "Adding gradle user and group" \
&& addgroup --system --gid 1000 gradle \
&& adduser --system --ingroup gradle --uid 1000 --shell /bin/ash gradle \
&& mkdir /home/gradle/.gradle \
&& chown -R gradle:gradle /home/gradle \
\
&& echo "Symlinking root Gradle cache to gradle Gradle cache" \
&& ln -s /home/gradle/.gradle /root/.gradle \
\
&& echo "Ensuring Gradle detects installed JDKs" \
&& echo "org.gradle.java.installations.auto-detect=false" > /home/gradle/.gradle/gradle.properties \
&& echo "org.gradle.java.installations.auto-download=false" >> /home/gradle/.gradle/gradle.properties \
&& echo "org.gradle.java.installations.fromEnv=JAVA21_HOME,JAVA22_HOME" >> /home/gradle/.gradle/gradle.properties

VOLUME /home/gradle/.gradle

WORKDIR /home/gradle

RUN set -o errexit -o nounset \
&& echo "Installing VCSes" \
&& apk add --no-cache \
git \
git-lfs \
mercurial \
subversion \
\
&& echo "Testing VCSes" \
&& which git \
&& which git-lfs \
&& which hg \
&& which svn

ENV GRADLE_VERSION 8.7
ARG GRADLE_DOWNLOAD_SHA256=544c35d6bd849ae8a5ed0bcea39ba677dc40f49df7d1835561582da2009b961d
RUN set -o errexit -o nounset \
&& echo "Downloading Gradle" \
&& wget --no-verbose --output-document=gradle.zip "https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip" \
\
&& echo "Checking Gradle download hash" \
&& echo "${GRADLE_DOWNLOAD_SHA256} *gradle.zip" | sha256sum -c - \
\
&& echo "Installing Gradle" \
&& unzip gradle.zip \
&& rm gradle.zip \
&& mv "gradle-${GRADLE_VERSION}" "${GRADLE_HOME}/" \
&& ln -s "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle

USER gradle

RUN set -o errexit -o nounset \
&& echo "Testing Gradle installation" \
&& gradle --version

USER root
137 changes: 137 additions & 0 deletions jdk21and22-graal/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
FROM ubuntu:jammy

CMD ["gradle"]

ENV GRADLE_HOME /opt/gradle

RUN set -o errexit -o nounset \
&& echo "Adding gradle user and group" \
&& groupadd --system --gid 1000 gradle \
&& useradd --system --gid gradle --uid 1000 --shell /bin/bash --create-home gradle \
&& mkdir /home/gradle/.gradle \
\
&& echo "Symlinking root Gradle cache to gradle Gradle cache" \
&& ln --symbolic /home/gradle/.gradle /root/.gradle \
\
&& echo "Ensuring Gradle detects installed JDKs" \
&& echo "org.gradle.java.installations.auto-detect=false" > /home/gradle/.gradle/gradle.properties \
&& echo "org.gradle.java.installations.auto-download=false" >> /home/gradle/.gradle/gradle.properties \
&& echo "org.gradle.java.installations.fromEnv=JAVA21_HOME,JAVA22_HOME" >> /home/gradle/.gradle/gradle.properties

VOLUME /home/gradle/.gradle

WORKDIR /home/gradle

RUN set -o errexit -o nounset \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install --yes --no-install-recommends \
binutils \
ca-certificates \
curl \
fontconfig \
locales \
p11-kit \
tzdata \
unzip \
wget \
\
gcc \
libc-dev \
libz-dev \
zlib1g-dev \
\
bzr \
git \
git-lfs \
mercurial \
openssh-client \
subversion \
&& rm --recursive --force /var/lib/apt/lists/* \
\
&& echo "Testing VCSes" \
&& which bzr \
&& which git \
&& which git-lfs \
&& which hg \
&& which svn

ENV JAVA_HOME=/opt/java/graalvm
ENV JAVA21_HOME /opt/java/graalvm21
ENV JAVA22_HOME /opt/java/graalvm22
RUN set -o errexit -o nounset \
&& mkdir /opt/java \
\
&& echo "Downloading GraalVM 21" \
&& JDK_21_VERSION=21.0.2 \
&& GRAALVM_AMD64_DOWNLOAD_SHA256=b048069aaa3a99b84f5b957b162cc181a32a4330cbc35402766363c5be76ae48 \
&& GRAALVM_AARCH64_DOWNLOAD_SHA256=a34be691ce68f0acf4655c7c6c63a9a49ed276a11859d7224fd94fc2f657cd7a \
&& ARCHITECTURE=$(dpkg --print-architecture) \
&& if [ "${ARCHITECTURE}" = "amd64" ]; then GRAALVM_ARCHITECTURE=linux-x64; fi \
&& if [ "${ARCHITECTURE}" = "arm64" ]; then GRAALVM_ARCHITECTURE=linux-aarch64; fi \
&& GRAALVM_PKG=https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${JDK_21_VERSION}/graalvm-community-jdk-${JDK_21_VERSION}_${GRAALVM_ARCHITECTURE}_bin.tar.gz \
&& wget --no-verbose --output-document=graalvm.tar.gz "${GRAALVM_PKG}" \
\
&& echo "Checking GraalVM 21 download hash" \
&& if [ "${ARCHITECTURE}" = "amd64" ]; then GRAALVM_DOWNLOAD_SHA256="${GRAALVM_AMD64_DOWNLOAD_SHA256}"; fi \
&& if [ "${ARCHITECTURE}" = "arm64" ]; then GRAALVM_DOWNLOAD_SHA256="${GRAALVM_AARCH64_DOWNLOAD_SHA256}"; fi \
&& echo "${GRAALVM_DOWNLOAD_SHA256} *graalvm.tar.gz" | sha256sum --check - \
\
&& echo "Installing GraalVM 21" \
&& tar --extract --gunzip --file graalvm.tar.gz \
&& rm graalvm.tar.gz \
&& mv graalvm-* /opt/java/graalvm21 \
\
&& echo "Downloading GraalVM 22" \
&& JDK_22_VERSION=22.0.0 \
&& GRAALVM_AMD64_DOWNLOAD_SHA256=e5eeb486a23101753f18181d002c3ede9da13c463fb61d3ea448abe774db0657 \
&& GRAALVM_AARCH64_DOWNLOAD_SHA256=da9a0e11b110ebccff33ade502516d00f574ec3247868007e452cef4143e0904 \
&& ARCHITECTURE=$(dpkg --print-architecture) \
&& if [ "${ARCHITECTURE}" = "amd64" ]; then GRAALVM_ARCHITECTURE=linux-x64; fi \
&& if [ "${ARCHITECTURE}" = "arm64" ]; then GRAALVM_ARCHITECTURE=linux-aarch64; fi \
&& GRAALVM_PKG=https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${JDK_22_VERSION}/graalvm-community-jdk-${JDK_22_VERSION}_${GRAALVM_ARCHITECTURE}_bin.tar.gz \
&& wget --no-verbose --output-document=graalvm.tar.gz "${GRAALVM_PKG}" \
\
&& echo "Checking GraalVM 22 download hash" \
&& if [ "${ARCHITECTURE}" = "amd64" ]; then GRAALVM_DOWNLOAD_SHA256="${GRAALVM_AMD64_DOWNLOAD_SHA256}"; fi \
&& if [ "${ARCHITECTURE}" = "arm64" ]; then GRAALVM_DOWNLOAD_SHA256="${GRAALVM_AARCH64_DOWNLOAD_SHA256}"; fi \
&& echo "${GRAALVM_DOWNLOAD_SHA256} *graalvm.tar.gz" | sha256sum --check - \
\
&& echo "Installing GraalVM 22" \
&& tar --extract --gunzip --file graalvm.tar.gz \
&& rm graalvm.tar.gz \
&& mv graalvm-* /opt/java/graalvm22 \
\
&& echo "Default Java to GraalVM 21" \
&& ln --symbolic /opt/java/graalvm21 /opt/java/graalvm \
&& for bin in /opt/java/graalvm21/bin/*; do \
base="$(basename "$bin")"; \
[ ! -e "/usr/bin/$base" ]; \
update-alternatives --install "/usr/bin/${base}" "${base}" "${bin}" 1; \
done \
\
&& echo "Testing GraalVM installation" \
&& java --version \
&& javac --version \
&& native-image --version

ENV GRADLE_VERSION 8.7
ARG GRADLE_DOWNLOAD_SHA256=544c35d6bd849ae8a5ed0bcea39ba677dc40f49df7d1835561582da2009b961d
RUN set -o errexit -o nounset \
&& echo "Downloading Gradle" \
&& wget --no-verbose --output-document=gradle.zip "https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip" \
\
&& echo "Checking Gradle download hash" \
&& echo "${GRADLE_DOWNLOAD_SHA256} *gradle.zip" | sha256sum --check - \
\
&& echo "Installing Gradle" \
&& unzip gradle.zip \
&& rm gradle.zip \
&& mv "gradle-${GRADLE_VERSION}" "${GRADLE_HOME}/" \
&& ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle \
\
&& echo "Testing Gradle installation" \
&& gradle --version \
\
# chown last so that it applies to /home/gradle/.gradle/native
&& chown --recursive gradle:gradle /home/gradle
69 changes: 69 additions & 0 deletions jdk21and22/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
FROM eclipse-temurin:22-jdk-jammy AS java22

FROM eclipse-temurin:21-jdk-jammy

COPY --from=java22 /opt/java/openjdk /opt/java/openjdk22
ENV JAVA21_HOME /opt/java/openjdk21
ENV JAVA22_HOME /opt/java/openjdk22

CMD ["gradle"]

ENV GRADLE_HOME /opt/gradle

RUN set -o errexit -o nounset \
&& echo "Adding gradle user and group" \
&& groupadd --system --gid 1000 gradle \
&& useradd --system --gid gradle --uid 1000 --shell /bin/bash --create-home gradle \
&& mkdir /home/gradle/.gradle \
&& chown --recursive gradle:gradle /home/gradle \
\
&& echo "Symlinking root Gradle cache to gradle Gradle cache" \
&& ln --symbolic /home/gradle/.gradle /root/.gradle \
\
&& echo "Ensuring Gradle detects installed JDKs" \
&& echo "org.gradle.java.installations.auto-detect=false" > /home/gradle/.gradle/gradle.properties \
&& echo "org.gradle.java.installations.auto-download=false" >> /home/gradle/.gradle/gradle.properties \
&& echo "org.gradle.java.installations.fromEnv=JAVA21_HOME,JAVA22_HOME" >> /home/gradle/.gradle/gradle.properties

VOLUME /home/gradle/.gradle

WORKDIR /home/gradle

RUN set -o errexit -o nounset \
&& apt-get update \
&& apt-get install --yes --no-install-recommends \
unzip \
wget \
\
bzr \
git \
git-lfs \
mercurial \
openssh-client \
subversion \
&& rm --recursive --force /var/lib/apt/lists/* \
\
&& echo "Testing VCSes" \
&& which bzr \
&& which git \
&& which git-lfs \
&& which hg \
&& which svn

ENV GRADLE_VERSION 8.7
ARG GRADLE_DOWNLOAD_SHA256=544c35d6bd849ae8a5ed0bcea39ba677dc40f49df7d1835561582da2009b961d
RUN set -o errexit -o nounset \
&& echo "Downloading Gradle" \
&& wget --no-verbose --output-document=gradle.zip "https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip" \
\
&& echo "Checking download hash" \
&& echo "${GRADLE_DOWNLOAD_SHA256} *gradle.zip" | sha256sum --check - \
\
&& echo "Installing Gradle" \
&& unzip gradle.zip \
&& rm gradle.zip \
&& mv "gradle-${GRADLE_VERSION}" "${GRADLE_HOME}/" \
&& ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle \
\
&& echo "Testing Gradle installation" \
&& gradle --version
18 changes: 15 additions & 3 deletions test-graal/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,20 @@ tasks.named('test') {
}

graalvmNative {
binaries.all {
resources.autodetect()
binaries {
all {
resources.autodetect()
}
main {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(00)
}
}
}
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(00)
}
toolchainDetection = false
}
6 changes: 6 additions & 0 deletions test/lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ dependencies {
tasks.named<Test>("test") {
useJUnitPlatform()
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(00)
}
}
Loading

0 comments on commit 8e92ea8

Please sign in to comment.