Skip to content

Commit 455153e

Browse files
Use Azul Zulu JDK8 distribution instead of Adoptium/OpenJDK on MacOS with Apple Silicon (#87733) (#87935)
# Conflicts: # x-pack/qa/repository-old-versions/build.gradle Co-authored-by: Amey Kulkarni <[email protected]>
1 parent c7dd1c8 commit 455153e

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

build-tools/src/main/java/org/elasticsearch/gradle/Jdk.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
public class Jdk implements Buildable, Iterable<File> {
2424

2525
private static final List<String> ALLOWED_ARCHITECTURES = List.of("aarch64", "x64");
26-
private static final List<String> ALLOWED_VENDORS = List.of("adoptium", "openjdk");
26+
private static final List<String> ALLOWED_VENDORS = List.of("adoptium", "openjdk", "zulu");
2727
private static final List<String> ALLOWED_PLATFORMS = List.of("darwin", "linux", "windows", "mac");
2828
private static final Pattern VERSION_PATTERN = Pattern.compile(
2929
"(\\d+)(\\.\\d+\\.\\d+(?:\\.\\d+)?)?\\+(\\d+(?:\\.\\d+)?)(@([a-f0-9]{32}))?"
@@ -37,6 +37,7 @@ public class Jdk implements Buildable, Iterable<File> {
3737
private final Property<String> version;
3838
private final Property<String> platform;
3939
private final Property<String> architecture;
40+
private final Property<String> distributionVersion;
4041
private String baseVersion;
4142
private String major;
4243
private String build;
@@ -49,6 +50,7 @@ public class Jdk implements Buildable, Iterable<File> {
4950
this.version = objectFactory.property(String.class);
5051
this.platform = objectFactory.property(String.class);
5152
this.architecture = objectFactory.property(String.class);
53+
this.distributionVersion = objectFactory.property(String.class);
5254
}
5355

5456
public String getName() {
@@ -104,6 +106,14 @@ public void setArchitecture(final String architecture) {
104106
this.architecture.set(architecture);
105107
}
106108

109+
public String getDistributionVersion() {
110+
return distributionVersion.get();
111+
}
112+
113+
public void setDistributionVersion(String distributionVersion) {
114+
this.distributionVersion.set(distributionVersion);
115+
}
116+
107117
public String getBaseVersion() {
108118
return baseVersion;
109119
}
@@ -179,6 +189,7 @@ void finalizeValues() {
179189
platform.finalizeValue();
180190
vendor.finalizeValue();
181191
architecture.finalizeValue();
192+
distributionVersion.finalizeValue();
182193
}
183194

184195
@Override

build-tools/src/main/java/org/elasticsearch/gradle/JdkDownloadPlugin.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class JdkDownloadPlugin implements Plugin<Project> {
2626

2727
public static final String VENDOR_ADOPTIUM = "adoptium";
2828
public static final String VENDOR_OPENJDK = "openjdk";
29+
public static final String VENDOR_ZULU = "zulu";
2930

3031
private static final String REPO_NAME_PREFIX = "jdk_repo_";
3132
private static final String EXTENSION_NAME = "jdks";
@@ -125,6 +126,17 @@ private void setupRepository(Project project, Jdk jdk) {
125126
+ jdk.getBuild()
126127
+ "/GPL/openjdk-[revision]_[module]-[classifier]_bin.[ext]";
127128
}
129+
} else if (jdk.getVendor().equals(VENDOR_ZULU)) {
130+
repoUrl = "https://cdn.azul.com";
131+
if (jdk.getMajor().equals("8") && isJdkOnMacOsPlatform(jdk) && jdk.getArchitecture().equals("aarch64")) {
132+
artifactPattern = "zulu/bin/zulu"
133+
+ jdk.getDistributionVersion()
134+
+ "-ca-jdk"
135+
+ jdk.getBaseVersion().replace("u", ".0.")
136+
+ "-[module]x_[classifier].[ext]";
137+
} else {
138+
throw new GradleException("JDK vendor zulu is supported only for JDK8 on MacOS with Apple Silicon.");
139+
}
128140
} else {
129141
throw new GradleException("Unknown JDK vendor [" + jdk.getVendor() + "]");
130142
}
@@ -147,14 +159,16 @@ public static NamedDomainObjectContainer<Jdk> getContainer(Project project) {
147159
}
148160

149161
private static String dependencyNotation(Jdk jdk) {
150-
String platformDep = jdk.getPlatform().equals("darwin") || jdk.getPlatform().equals("mac")
151-
? (jdk.getVendor().equals(VENDOR_ADOPTIUM) ? "mac" : "macos")
152-
: jdk.getPlatform();
162+
String platformDep = isJdkOnMacOsPlatform(jdk) ? (jdk.getVendor().equals(VENDOR_ADOPTIUM) ? "mac" : "macos") : jdk.getPlatform();
153163
String extension = jdk.getPlatform().equals("windows") ? "zip" : "tar.gz";
154164

155165
return groupName(jdk) + ":" + platformDep + ":" + jdk.getBaseVersion() + ":" + jdk.getArchitecture() + "@" + extension;
156166
}
157167

168+
private static boolean isJdkOnMacOsPlatform(Jdk jdk) {
169+
return jdk.getPlatform().equals("darwin") || jdk.getPlatform().equals("mac");
170+
}
171+
158172
private static String groupName(Jdk jdk) {
159173
return jdk.getVendor() + "_" + jdk.getMajor();
160174
}

build-tools/src/test/java/org/elasticsearch/gradle/JdkDownloadPluginTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void testUnknownVendor() {
3636
"11.0.2+33",
3737
"linux",
3838
"x64",
39-
"unknown vendor [unknown] for jdk [testjdk], must be one of [adoptium, openjdk]"
39+
"unknown vendor [unknown] for jdk [testjdk], must be one of [adoptium, openjdk, zulu]"
4040
);
4141
}
4242

modules/reindex/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ jdks {
9393
}
9494
}
9595

96+
if (Os.isFamily(Os.FAMILY_MAC) && Architecture.current() == Architecture.AARCH64) {
97+
jdks.legacy.vendor = 'zulu'
98+
jdks.legacy.distributionVersion = '8.56.0.23'
99+
}
100+
96101
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
97102
logger.warn("Disabling reindex-from-old tests because we can't get the pid file on windows")
98103
tasks.named("javaRestTest").configure {

0 commit comments

Comments
 (0)