Skip to content

Commit

Permalink
Remove requirement for directories to contain Java versions
Browse files Browse the repository at this point in the history
  • Loading branch information
keeganwitt committed Apr 5, 2024
1 parent 943f22d commit 13585dd
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 48 deletions.
74 changes: 52 additions & 22 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,72 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version:
- jdk11
- jdk11-alpine
- jdk11-focal
- jdk17
- jdk17-alpine
- jdk17-focal
- jdk17-graal
- jdk17-focal-graal
- jdk21
- jdk21-alpine
- jdk21-graal
- jdk21and22
- jdk21and22-alpine
- jdk21and22-graal
versions:
- directory: jdk11
ltsJavaVersion: 11
- directory: jdk11-alpine
ltsJavaVersion: 11
variant: alpine
- directory: jdk11-focal
ltsJavaVersion: 11
variant: focal
- directory: jdk17
ltsJavaVersion: 17
- directory: jdk17-alpine
ltsJavaVersion: 17
variant: alpine
- directory: jdk17-focal
ltsJavaVersion: 17
variant: focal
- directory: jdk17-graal
ltsJavaVersion: 17
variant: graal
- directory: jdk17-focal-graal
ltsJavaVersion: 17
variant: focal-graal
- directory: jdk21
ltsJavaVersion: 21
- directory: jdk21-alpine
ltsJavaVersion: 21
variant: alpine
- directory: jdk21-graal
ltsJavaVersion: 21
variant: graal
- directory: jdk-lts-and-current
ltsJavaVersion: 21
currentJavaVersion: 22
- directory: jdk-lts-and-current-alpine
ltsJavaVersion: 21
currentJavaVersion: 22
variant: alpine
- directory: jdk-lts-and-current-graal
ltsJavaVersion: 21
currentJavaVersion: 22
variant: graal
steps:
- name: checkout
uses: actions/checkout@v2
- name: build
env:
version: ${{ matrix.version }}
directory: ${{ matrix.versions.directory }}
run: |
cd "${version}"
cd "${directory}"
grep "FROM " Dockerfile | cut -d' ' -f2 | xargs -I{} docker pull {}
docker build --tag "gradle:${version}" .
docker build --tag "gradle:${directory}" .
- name: test
env:
version: ${{ matrix.version }}
directory: ${{ matrix.versions.directory }}
ltsJavaVersion: ${{ matrix.versions.ltsJavaVersion }}
currentJavaVersion: ${{ matrix.versions.currentJavaVersion }}
variant: ${{ matrix.versions.variant }}
expectedGradleVersion: "8.7"
run: |
toolchainJavaVersion=$(echo "${version}" | grep --extended-regex --only-matching '[0-9]+' | tail --lines -1)
if [[ "${version}" =~ "graal" ]]; then
toolchainJavaVersion="${currentJavaVersion:-${ltsJavaVersion}}"
if [[ "${variant:-''}" = "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}"
./run.sh "gradle:${directory}" "${expectedGradleVersion}"
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
* [jdk21, jdk21-jammy](https://github.com/keeganwitt/docker-gradle/blob/master/jdk21/Dockerfile)
* [jdk21-alpine](https://github.com/keeganwitt/docker-gradle/blob/master/jdk21-alpine/Dockerfile)
* [jdk21-graal](https://github.com/keeganwitt/docker-gradle/blob/master/jdk21-graal/Dockerfile)
* [jdk-lts-and-current](https://github.com/keeganwitt/docker-gradle/blob/master/jdk21and22/Dockerfile)
* [jdk-lts-and-current-alpine](https://github.com/keeganwitt/docker-gradle/blob/master/jdk21and22-alpine/Dockerfile)
* [jdk-lts-and-current-graal](https://github.com/keeganwitt/docker-gradle/blob/master/jdk21and22-graal/Dockerfile)
* [jdk-lts-and-current](https://github.com/keeganwitt/docker-gradle/blob/master/jdk-lts-and-current/Dockerfile)
* [jdk-lts-and-current-alpine](https://github.com/keeganwitt/docker-gradle/blob/master/jdk-lts-and-current-alpine/Dockerfile)
* [jdk-lts-and-current-graal](https://github.com/keeganwitt/docker-gradle/blob/master/jdk-lts-and-current-graal/Dockerfile)

## What is Gradle?

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM eclipse-temurin:22-jdk-alpine AS java22
FROM eclipse-temurin:22-jdk-alpine AS java_current

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
COPY --from=java_current /opt/java/openjdk /opt/java/openjdk22
ENV JAVA_LTS_HOME /opt/java/openjdk21
ENV JAVA_CURRENT_HOME /opt/java/openjdk22

CMD ["gradle"]

Expand All @@ -23,7 +23,7 @@ RUN set -o errexit -o nounset \
&& 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
&& echo "org.gradle.java.installations.fromEnv=JAVA_LTS_HOME,JAVA_CURRENT_HOME" >> /home/gradle/.gradle/gradle.properties

VOLUME /home/gradle/.gradle

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN set -o errexit -o nounset \
&& 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
&& echo "org.gradle.java.installations.fromEnv=JAVA_LTS_HOME,JAVA_CURRENT_HOME" >> /home/gradle/.gradle/gradle.properties

VOLUME /home/gradle/.gradle

Expand Down Expand Up @@ -57,13 +57,13 @@ RUN set -o errexit -o nounset \
&& which svn

ENV JAVA_HOME=/opt/java/graalvm
ENV JAVA21_HOME /opt/java/graalvm21
ENV JAVA22_HOME /opt/java/graalvm22
ENV JAVA_LTS_HOME /opt/java/graalvm21
ENV JAVA_CURRENT_HOME /opt/java/graalvm22
RUN set -o errexit -o nounset \
&& mkdir /opt/java \
\
&& echo "Downloading GraalVM 21" \
&& JDK_21_VERSION=21.0.2 \
&& echo "Downloading LTS GraalVM" \
&& JDK_VERSION=21.0.2 \
&& GRAALVM_AMD64_DOWNLOAD_SHA256=b048069aaa3a99b84f5b957b162cc181a32a4330cbc35402766363c5be76ae48 \
&& GRAALVM_AARCH64_DOWNLOAD_SHA256=a34be691ce68f0acf4655c7c6c63a9a49ed276a11859d7224fd94fc2f657cd7a \
&& ARCHITECTURE=$(dpkg --print-architecture) \
Expand All @@ -72,37 +72,37 @@ RUN set -o errexit -o nounset \
&& 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" \
&& echo "Checking LTS GraalVM 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" \
&& echo "Installing LTS GraalVM" \
&& 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 \
&& echo "Downloading current GraalVM" \
&& JDK_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 \
&& GRAALVM_PKG=https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${JDK_VERSION}/graalvm-community-jdk-${JDK_VERSION}_${GRAALVM_ARCHITECTURE}_bin.tar.gz \
&& wget --no-verbose --output-document=graalvm.tar.gz "${GRAALVM_PKG}" \
\
&& echo "Checking GraalVM 22 download hash" \
&& echo "Checking current GraalVM 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" \
&& echo "Installing current GraalVM" \
&& tar --extract --gunzip --file graalvm.tar.gz \
&& rm graalvm.tar.gz \
&& mv graalvm-* /opt/java/graalvm22 \
\
&& echo "Default Java to GraalVM 21" \
&& echo "Default Java to LTS GraalVM" \
&& ln --symbolic /opt/java/graalvm21 /opt/java/graalvm \
&& for bin in /opt/java/graalvm21/bin/*; do \
base="$(basename "$bin")"; \
Expand Down
10 changes: 5 additions & 5 deletions jdk21and22/Dockerfile → jdk-lts-and-current/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM eclipse-temurin:22-jdk-jammy AS java22
FROM eclipse-temurin:22-jdk-jammy AS java_current

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
COPY --from=java_current /opt/java/openjdk /opt/java/openjdk22
ENV JAVA_LTS_HOME /opt/java/openjdk21
ENV JAVA_CURRENT_HOME /opt/java/openjdk22

CMD ["gradle"]

Expand All @@ -23,7 +23,7 @@ RUN set -o errexit -o nounset \
&& 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
&& echo "org.gradle.java.installations.fromEnv=JAVA_LTS_HOME,JAVA_CURRENT_HOME" >> /home/gradle/.gradle/gradle.properties

VOLUME /home/gradle/.gradle

Expand Down

0 comments on commit 13585dd

Please sign in to comment.