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 3c12b9a commit aa06599
Show file tree
Hide file tree
Showing 8 changed files with 337 additions and 14 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]+-' | sed 's/-//')
if [[ "${version}" =~ "graal" ]]; then
cd test-graal
sed --in-place "s/(00)/(${toolchainJavaVersion})/" app/build.gradle
else
cd test
sed --in-place "s/(00)/(${toolchainJavaVersion})/" lib/build.gradle.kts
fi
./run.sh "gradle:${version}" "${expectedGradleVersion}"
69 changes: 69 additions & 0 deletions jdk21and22-alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
FROM eclipse-temurin:21-jdk-alpine AS java21

FROM eclipse-temurin:21-jdk-alpine

COPY --from=java21 /opt/java/openjdk /opt/java/openjdk21
RUN set -o errexit -o nounset \
&& ln -s /opt/java/openjdk21 /opt/java/openjdk
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 uses Java 21" \
&& 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" >> /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 uses Java 20" \
&& 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=JAVA20_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 22" \
&& ln --symbolic /opt/java/graalvm22 /opt/java/graalvm \
&& for bin in /opt/java/graalvm22/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
71 changes: 71 additions & 0 deletions jdk21and22/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
FROM eclipse-temurin:22-jdk-jammy AS java22

FROM eclipse-temurin:21-jdk-jammy

COPY --from=java22 /opt/java/openjdk /opt/java/openjdk22
RUN set -o errexit -o nounset \
&& ln --symbolic /opt/java/openjdk21 /opt/java/openjdk
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 uses Java 22" \
&& 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=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
6 changes: 6 additions & 0 deletions test-graal/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@ graalvmNative {
}
toolchainDetection = false
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(00)
}
}
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)
}
}
24 changes: 20 additions & 4 deletions update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,54 @@ $gradleVersion = $((Invoke-WebRequest "https://services.gradle.org/versions/curr
$sha = $(Invoke-RestMethod -Uri "https://downloads.gradle.org/distributions/gradle-${gradleVersion}-bin.zip.sha256")

$wc = [System.Net.WebClient]::new()
$graal17Version = $(((Invoke-WebRequest "https://api.github.com/repos/graalvm/graalvm-ce-builds/releases?per_page=6&page=1" | ConvertFrom-Json).tag_name | Select-String -Pattern "jdk-17" | Select-Object -First 1).ToString().Replace("jdk-", ""))
$graal17Version = $(((Invoke-WebRequest "https://api.github.com/repos/graalvm/graalvm-ce-builds/releases?per_page=12&page=1" | ConvertFrom-Json).tag_name | Select-String -Pattern "jdk-17" | Select-Object -First 1).ToString().Replace("jdk-", ""))
$graal17amd64Hash = (Get-FileHash -Algorithm SHA256 -InputStream ($wc.OpenRead("https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${graal17Version}/graalvm-community-jdk-${graal17Version}_linux-x64_bin.tar.gz"))).Hash.ToLower()
$graal17aarch64Hash = (Get-FileHash -Algorithm SHA256 -InputStream ($wc.OpenRead("https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${graal17Version}/graalvm-community-jdk-${graal17Version}_linux-aarch64_bin.tar.gz"))).Hash.ToLower()

$graal21Version = $(((Invoke-WebRequest "https://api.github.com/repos/graalvm/graalvm-ce-builds/releases?per_page=6&page=1" | ConvertFrom-Json).tag_name | Select-String -Pattern "jdk-21" | Select-Object -First 1).ToString().Replace("jdk-", ""))
$graal21Version = $(((Invoke-WebRequest "https://api.github.com/repos/graalvm/graalvm-ce-builds/releases?per_page=12&page=1" | ConvertFrom-Json).tag_name | Select-String -Pattern "jdk-21" | Select-Object -First 1).ToString().Replace("jdk-", ""))
$graal21amd64Hash = (Get-FileHash -Algorithm SHA256 -InputStream ($wc.OpenRead("https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${graal21Version}/graalvm-community-jdk-${graal21Version}_linux-x64_bin.tar.gz"))).Hash.ToLower()
$graal21aarch64Hash = (Get-FileHash -Algorithm SHA256 -InputStream ($wc.OpenRead("https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${graal21Version}/graalvm-community-jdk-${graal21Version}_linux-aarch64_bin.tar.gz"))).Hash.ToLower()

$graal22Version = $(((Invoke-WebRequest "https://api.github.com/repos/graalvm/graalvm-ce-builds/releases?per_page=12&page=1" | ConvertFrom-Json).tag_name | Select-String -Pattern "jdk-22" | Select-Object -First 1).ToString().Replace("jdk-", ""))
$graal22amd64Hash = (Get-FileHash -Algorithm SHA256 -InputStream ($wc.OpenRead("https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${graal22Version}/graalvm-community-jdk-${graal22Version}_linux-x64_bin.tar.gz"))).Hash.ToLower()
$graal22aarch64Hash = (Get-FileHash -Algorithm SHA256 -InputStream ($wc.OpenRead("https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${graal22Version}/graalvm-community-jdk-${graal22Version}_linux-aarch64_bin.tar.gz"))).Hash.ToLower()

Write-Host "Latest Gradle version is $gradleVersion"
Write-Host "Latest Graal 17 version is $graal17Version"
Write-Host "Latest Graal 21 version is $graal21Version"
Write-Host "Latest Graal 22 version is $graal22Version"

Write-Host "Graal 17 AMD64 hash is $graal17amd64Hash"
Write-Host "Graal 17 AARCH64 hash is $graal17aarch64Hash"
Write-Host "Graal 21 AMD64 hash is $graal21amd64Hash"
Write-Host "Graal 21 AARCH64 hash is $graal21aarch64Hash"
Write-Host "Graal 22 AMD64 hash is $graal22amd64Hash"
Write-Host "Graal 22 AARCH64 hash is $graal22aarch64Hash"

dir -Recurse -Filter Dockerfile | ForEach-Object {
(Get-Content -Path $_.FullName) -replace "ENV GRADLE_VERSION .+$", "ENV GRADLE_VERSION ${gradleVersion}" | Set-Content $_.FullName
(Get-Content -Path $_.FullName) -replace "GRADLE_DOWNLOAD_SHA256=.+$", "GRADLE_DOWNLOAD_SHA256=${sha}" | Set-Content $_.FullName
if ($((Get-Item $_.FullName).Directory.Name) -match "jdk17.+graal")
if ($((Get-Item $_.FullName).Directory.Name) -eq "jdk17-graal" -Or $((Get-Item $_.FullName).Directory.Name) -eq "jdk17-focal-graal")
{
(Get-Content -Path $_.FullName) -replace "JAVA_VERSION=[^ ]+", "JAVA_VERSION=${graal17Version}" | Set-Content $_.FullName
(Get-Content -Path $_.FullName) -replace "GRAALVM_AMD64_DOWNLOAD_SHA256=[^ ]+", "GRAALVM_AMD64_DOWNLOAD_SHA256=${graal17amd64Hash}" | Set-Content $_.FullName
(Get-Content -Path $_.FullName) -replace "GRAALVM_AARCH64_DOWNLOAD_SHA256=[^ ]+", "GRAALVM_AARCH64_DOWNLOAD_SHA256=${graal17aarch64Hash}" | Set-Content $_.FullName
}
if ($((Get-Item $_.FullName).Directory.Name) -match "jdk21.+graal")
elseif ($((Get-Item $_.FullName).Directory.Name) -eq "jdk21-graal")
{
(Get-Content -Path $_.FullName) -replace "JAVA_VERSION=[^ ]+", "JAVA_VERSION=${graal21Version}" | Set-Content $_.FullName
(Get-Content -Path $_.FullName) -replace "GRAALVM_AMD64_DOWNLOAD_SHA256=[^ ]+", "GRAALVM_AMD64_DOWNLOAD_SHA256=${graal21amd64Hash}" | Set-Content $_.FullName
(Get-Content -Path $_.FullName) -replace "GRAALVM_AARCH64_DOWNLOAD_SHA256=[^ ]+", "GRAALVM_AARCH64_DOWNLOAD_SHA256=${graal21aarch64Hash}" | Set-Content $_.FullName
}
elseif ($((Get-Item $_.FullName).Directory.Name) -eq "jdk21and22-graal")
{
(Get-Content -Path $_.FullName) -replace "JAVA_21_VERSION=[^ ]+", "JAVA_21_VERSION=${graal21Version}" | Set-Content $_.FullName
(Get-Content -Path $_.FullName) -replace "GRAALVM_21_AMD64_DOWNLOAD_SHA256=[^ ]+", "GRAALVM_21_AMD64_DOWNLOAD_SHA256=${graal21amd64Hash}" | Set-Content $_.FullName
(Get-Content -Path $_.FullName) -replace "GRAALVM_21_AARCH64_DOWNLOAD_SHA256=[^ ]+", "GRAALVM_21_AARCH64_DOWNLOAD_SHA256=${graal21aarch64Hash}" | Set-Content $_.FullName
(Get-Content -Path $_.FullName) -replace "JAVA_22_VERSION=[^ ]+", "JAVA_22_VERSION=${graal22Version}" | Set-Content $_.FullName
(Get-Content -Path $_.FullName) -replace "GRAALVM_22_AMD64_DOWNLOAD_SHA256=[^ ]+", "GRAALVM_22_AMD64_DOWNLOAD_SHA256=${graal22amd64Hash}" | Set-Content $_.FullName
(Get-Content -Path $_.FullName) -replace "GRAALVM_22_AARCH64_DOWNLOAD_SHA256=[^ ]+", "GRAALVM_22_AARCH64_DOWNLOAD_SHA256=${graal22aarch64Hash}" | Set-Content $_.FullName
}
}

(Get-Content -Path .github/workflows/ci.yaml) -replace "expectedGradleVersion: .+", "expectedGradleVersion: `"${gradleVersion}`"" | Set-Content .github/workflows/ci.yaml
Loading

0 comments on commit aa06599

Please sign in to comment.