Skip to content

Commit 160589e

Browse files
committed
Fix ea jdk selection not just based on major version
explicitly requires to add a ea postfix to the runtime sys property
1 parent 38c6430 commit 160589e

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

BUILDING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,11 @@ To test an unreleased development version of a third party dependency you have s
189189
### How do I test against java early access (ea) versions?
190190

191191
Currently only openjdk EA builds by oracle are supported.
192-
To test against an early access version java version you can pass the major java version
193-
to test against via system property (e.g. -Druntime.java=26):
192+
To test against an early access version java version you can pass the major
193+
java version appended with `-ea` as a system property (e.g. -Druntime.java=26-ea) to the Gradle build:
194194

195195
```
196-
./gradlew clean test -Druntime.java=26
196+
./gradlew clean test -Druntime.java=26-ea
197197
```
198198

199199
This will run the tests using the JDK 26 EA version and pick the latest available build of the matching JDK EA version we expose
@@ -202,7 +202,7 @@ in our custom jdk catalogue at `https://storage.googleapis.com/elasticsearch-jdk
202202
To run against a specific build number of the EA build you can pass a second system property (e.g. `-Druntime.java.build=6`):
203203

204204
```
205-
./gradlew clean test -Druntime.java=26 -Druntime.java.build=6
205+
./gradlew clean test -Druntime.java=26-ea -Druntime.java.build=6
206206
```
207207

208208
#### How to use a Maven based third party dependency via `mavenlocal`?

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/GlobalBuildInfoPlugin.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,14 +347,16 @@ private static void assertMinimumCompilerVersion(JavaVersion minimumCompilerVers
347347
}
348348

349349
private Provider<File> findRuntimeJavaHome() {
350-
Integer runtimeJavaProperty = Integer.getInteger("runtime.java");
350+
String runtimeJavaProperty = System.getProperty("runtime.java");
351+
351352
if (runtimeJavaProperty != null) {
352-
if (runtimeJavaProperty > Integer.parseInt(VersionProperties.getBundledJdkMajorVersion())) {
353+
if(runtimeJavaProperty.toLowerCase().endsWith("-ea")) {
353354
// handle EA builds differently due to lack of support in Gradle toolchain service
354355
// we resolve them using JdkDownloadPlugin for now.
355-
return resolveEarlyAccessJavaHome(runtimeJavaProperty);
356+
Integer major = Integer.parseInt(runtimeJavaProperty.substring(0, runtimeJavaProperty.length() - 3));
357+
return resolveEarlyAccessJavaHome(major);
356358
} else {
357-
return resolveJavaHomeFromToolChainService(runtimeJavaProperty.toString());
359+
return resolveJavaHomeFromToolChainService(runtimeJavaProperty);
358360
}
359361
}
360362
if (System.getenv("RUNTIME_JAVA_HOME") != null) {

0 commit comments

Comments
 (0)