Skip to content

Commit 4958189

Browse files
committed
Give the native jobs a JDK 21, which Gradle does not find on Windows
The Windows job failed in :open-java-format-spi:compileJava: no Java installation matched languageVersion=21. The jars compile with a Java 21 toolchain, and the native jobs set up only GraalVM 25. On Linux and macOS Gradle found the runner's preinstalled JDK 21 by its location, which hid the gap; on Windows it looks for JDKs in the registry, where the runner's are not. gradle.properties already names JDK21_HOME as the place to look, so the native jobs of both workflows now install a Temurin 21 and pass its path there. It comes before GraalVM, so that Gradle itself still runs on GraalVM 25. The same failure, reproduced locally with auto-detection off, goes away with JDK21_HOME set.
1 parent e8c0ee1 commit 4958189

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ jobs:
6565
steps:
6666
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
6767

68+
# The jars compile with a Java 21 toolchain, which gradle.properties looks up in JDK21_HOME. On
69+
# Linux and macOS Gradle also finds the runner's own JDK 21 by its location, on Windows it does not.
70+
# Installed before GraalVM, so that Gradle itself still runs on GraalVM.
71+
- name: Install JDK 21 for the jars
72+
id: jdk21
73+
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
74+
with:
75+
distribution: temurin
76+
java-version: '21'
77+
6878
- name: Install GraalVM 25 for the image
6979
uses: graalvm/setup-graalvm@5298d94fb55a4f185c602eeac5de1b553882abe2 # v1.6.4
7080
with:
@@ -74,6 +84,8 @@ jobs:
7484

7585
- name: Compile the native image
7686
run: ./gradlew -PnativeImage=true :open-java-format-native:nativeCompile
87+
env:
88+
JDK21_HOME: ${{ steps.jdk21.outputs.path }}
7789

7890
# The binary itself on a file that needs formatting, a formatted one and one that does not parse.
7991
# For the Windows binary this is the only check.
@@ -94,6 +106,8 @@ jobs:
94106
- name: Test the plugins against the image
95107
if: runner.os != 'Windows'
96108
run: ./gradlew -PnativeImage=true :open-java-format-jdk-bootstrap:test :gradle-open-java-format:test
109+
env:
110+
JDK21_HOME: ${{ steps.jdk21.outputs.path }}
97111

98112
- name: Publish Test Report
99113
uses: mikepenz/action-junit-report@a9170d5795813c01ab4901ffb045b52bab4ab09d # v6.5.0

‎.github/workflows/release.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ jobs:
8585
steps:
8686
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
8787

88+
# The Java 21 toolchain for the jars, through JDK21_HOME, as in ci.yml: Gradle does not find the
89+
# runner's own JDK 21 on Windows. Installed before GraalVM, so that Gradle still runs on GraalVM.
90+
- name: Install JDK 21 for the jars
91+
id: jdk21
92+
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
93+
with:
94+
distribution: temurin
95+
java-version: '21'
96+
8897
- name: Install GraalVM 25 for the image
8998
uses: graalvm/setup-graalvm@5298d94fb55a4f185c602eeac5de1b553882abe2 # v1.6.4
9099
with:
@@ -94,6 +103,8 @@ jobs:
94103

95104
- name: Compile the native image
96105
run: ./gradlew -PnativeImage=true :open-java-format-native:nativeCompile
106+
env:
107+
JDK21_HOME: ${{ steps.jdk21.outputs.path }}
97108

98109
- name: Hand the binary to the deploy job
99110
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1

0 commit comments

Comments
 (0)