8000 Fix Java installer on Mac hosts (#11740) · localstack/localstack@0a3816b · GitHub
[go: up one dir, main page]

Skip to content

Commit 0a3816b

Browse files
Fix Java installer on Mac hosts (#11740)
1 parent ec217fe commit 0a3816b

File tree

1 file changed

+15
-11
lines changed
  • localstack-core/localstack/packages

1 file changed

+15
-11
lines changed

localstack-core/localstack/packages/java.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
# Supported Java LTS versions mapped with Eclipse Temurin build semvers
2020
JAVA_VERSIONS = {
21-
"8": "8u422-b05",
22-
"11": "11.0.24+8",
23-
"17": "17.0.12+7",
24-
"21": "21.0.4+7",
21+
"8": "8u432-b06",
22+
"11": "11.0.25+9",
23+
"17": "17.0.13+11",
24+
"21": "21.0.5+11",
2525
}
2626

2727

@@ -77,6 +77,8 @@ def _get_install_marker_path(self, install_dir: str) -> str:
7777
return os.path.join(install_dir, "bin", "java")
7878

7979
def _get_download_url(self) -> str:
80+
# Note: Eclipse Temurin does not provide Mac aarch64 Java 8 builds.
81+
# See https://adoptium.net/en-GB/supported-platforms/
8082
try:
8183
LOG.debug("Determining the latest Java build version")
8284
return self._download_url_latest_release()
@@ -113,8 +115,8 @@ def _post_process(self, target: InstallTarget) -> None:
113115
"jdk.httpserver,jdk.management,jdk.management.agent,"
114116
# Required by Spark and Hadoop
115117
"java.security.jgss,jdk.security.auth,"
116-
# OpenSearch requires Thai locale for segmentation support
117-
"jdk.localedata --include-locales en,th "
118+
# Include required locales
119+
"jdk.localedata --include-locales en "
118120
# Supplementary args
119121
"--compress 2 --strip-debug --no-header-files --no-man-pages "
120122
# Output directory
@@ -132,18 +134,22 @@ def get_java_home(self) -> str | None:
132134
return self.get_installed_dir()
133135

134136
@property
135-
def arch(self) -> str:
137+
def arch(self) -> str | None:
136138
return (
137139
"x64" if get_arch() == Arch.amd64 else "aarch64" if get_arch() == Arch.arm64 else None
138140
)
139141

142+
@property
143+
def os_name(self) -> str | None:
144+
return "linux" if is_linux() else "mac" if is_mac_os() else None
145+
140146
def _download_url_latest_release(self) -> str:
141147
"""
142148
Return the download URL for latest stable JDK build.
143149
"""
144150
endpoint = (
145151
f"https://api.adoptium.net/v3/assets/latest/{self.version}/hotspot?"
146-
f"os=linux&architecture={self.arch}&image_type=jdk"
152+
f"os={self.os_name}&architecture={self.arch}&image_type=jdk"
147153
)
148154
# Override user-agent because Adoptium API denies service to `requests` library
149155
response = requests.get(endpoint, headers={"user-agent": USER_AGENT_STRING}).json()
@@ -153,8 +159,6 @@ def _download_url_fallback(self) -> str:
153159
"""
154160
Return the download URL for pinned JDK build.
155161
"""
156-
os = "linux" if is_linux() else "mac" if is_mac_os() else None
157-
158162
semver = JAVA_VERSIONS[self.version]
159163
tag_slug = f"jdk-{semver}"
160164
semver_safe = semver.replace("+", "_")
@@ -166,7 +170,7 @@ def _download_url_fallback(self) -> str:
166170

167171
return (
168172
f"https://github.com/adoptium/temurin{self.version}-binaries/releases/download/{tag_slug}/"
169-
f"OpenJDK{self.version}U-jdk_{self.arch}_{os}_hotspot_{semver_safe}.tar.gz"
173+
f"OpenJDK{self.version}U-jdk_{self.arch}_{self.os_name}_hotspot_{semver_safe}.tar.gz"
170174
)
171175

172176

0 commit comments

Comments
 (0)
0