forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve runtime java via Gradle tool chain provider (elastic#95319)
Using gradle toolchain support in gradle requires refactoring how the composite build is composed. We added three toolchain resolver 1. Resolver for resolving defined bundled version from oracle as openjdk 2. Resolve all available jdks from Adoption 3. Resolve archived Oracle jdk distributions. We should be able to remove the JdkDownloadPlugin altogether without having that in place, but we'll do that in a separate effort. Fixes elastic#95094
- Loading branch information
Showing
22 changed files
with
807 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...java/org/elasticsearch/gradle/internal/toolchain/AbstractCustomJavaToolchainResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.gradle.internal.toolchain; | ||
|
||
import org.gradle.jvm.toolchain.JavaToolchainResolver; | ||
import org.gradle.jvm.toolchain.JvmVendorSpec; | ||
import org.gradle.platform.Architecture; | ||
import org.gradle.platform.OperatingSystem; | ||
|
||
abstract class AbstractCustomJavaToolchainResolver implements JavaToolchainResolver { | ||
|
||
static String toOsString(OperatingSystem operatingSystem) { | ||
return toOsString(operatingSystem, null); | ||
} | ||
|
||
static String toOsString(OperatingSystem operatingSystem, JvmVendorSpec v) { | ||
return switch (operatingSystem) { | ||
case MAC_OS -> (v == null || v.equals(JvmVendorSpec.ADOPTIUM) == false) ? "macos" : "mac"; | ||
case LINUX -> "linux"; | ||
case WINDOWS -> "windows"; | ||
default -> throw new UnsupportedOperationException("Operating system " + operatingSystem); | ||
}; | ||
} | ||
|
||
static String toArchString(Architecture architecture) { | ||
return switch (architecture) { | ||
case X86_64 -> "x64"; | ||
case AARCH64 -> "aarch64"; | ||
case X86 -> "x86"; | ||
}; | ||
} | ||
|
||
protected static boolean anyVendorOr(JvmVendorSpec givenVendor, JvmVendorSpec expectedVendor) { | ||
return givenVendor.matches("any") || givenVendor.equals(expectedVendor); | ||
} | ||
} |
Oops, something went wrong.