Skip to content

Commit 99f8773

Browse files
committed
Force usage of a specific JDK version on macOS
1 parent cd3fed4 commit 99f8773

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pythonforandroid/prerequisites.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class JDKPrerequisite(Prerequisite):
151151
name = "JDK"
152152
mandatory = dict(linux=False, darwin=True)
153153
installer_is_supported = dict(linux=False, darwin=True)
154-
min_supported_version = 17
154+
supported_version = 17
155155

156156
def darwin_checker(self):
157157
if "JAVA_HOME" in os.environ:
@@ -197,21 +197,21 @@ def _darwin_jdk_is_supported(self, jdk_path):
197197
res = _stdout_res.strip().decode()
198198

199199
major_version = int(res.split(" ")[-1].split(".")[0])
200-
if major_version >= self.min_supported_version:
200+
if major_version == self.supported_version:
201201
info(f"Found a valid JDK at {jdk_path}")
202202
return True
203203
else:
204-
error(f"JDK {self.min_supported_version} or higher is required")
204+
error(f"JDK version {major_version} is not supported")
205205
return False
206206

207207
def darwin_helper(self):
208208
info(
209-
"python-for-android requires a JDK 17 or higher to be installed on macOS,"
209+
f"python-for-android requires a JDK {self.supported_version} to be installed on macOS,"
210210
"but seems like you don't have one installed."
211211
)
212212
info(
213213
"If you think that a valid JDK is already installed, please verify that "
214-
"you have a JDK 17 or higher installed and that `/usr/libexec/java_home` "
214+
f"you have a JDK {self.supported_version} installed and that `/usr/libexec/java_home` "
215215
"shows the correct path."
216216
)
217217
info(
@@ -221,12 +221,12 @@ def darwin_helper(self):
221221

222222
def darwin_installer(self):
223223
info(
224-
"Looking for a JDK 17 or higher installation which is not the default one ..."
224+
f"Looking for a JDK {self.supported_version} installation which is not the default one ..."
225225
)
226-
jdk_path = self._darwin_get_libexec_jdk_path(version="17+")
226+
jdk_path = self._darwin_get_libexec_jdk_path(version=str(self.supported_version))
227227

228228
if not self._darwin_jdk_is_supported(jdk_path):
229-
info("We're unlucky, there's no JDK 17 or higher installation available")
229+
info(f"We're unlucky, there's no JDK {self.supported_version} or higher installation available")
230230

231231
base_url = "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.2%2B8/"
232232
if platform.machine() == "arm64":

0 commit comments

Comments
 (0)