Add auto detect java installation support.

This commit is contained in:
2026-07-14 01:13:36 +08:00
parent bd5a1e8974
commit 425f740d8f
9 changed files with 546 additions and 200 deletions
+16 -4
View File
@@ -13,6 +13,11 @@ from core_lib.common.exception import JavaRuntimeException, JavaRuntimeParseExce
logger = logging.getLogger("Launcher.CoreLib")
def get_java_version(java_executable_path: str | Path) -> tuple[int, str]:
"""
Get java version by executing `java -version`
:param java_executable_path:
:return:
"""
if isinstance(java_executable_path, Path):
java_executable_path = java_executable_path.as_posix()
@@ -56,7 +61,14 @@ def get_java_version(java_executable_path: str | Path) -> tuple[int, str]:
return major, raw_version
def find_java_installations(extra_install_patterns: list | None=None) -> list[dict]:
def find_java_installations(extra_install_patterns: list | None=None) -> tuple[list[dict], list[Path]]:
"""
Find Java installations
:param extra_install_patterns:
:return:
installations: List[dict]
errors: List[Path]
"""
candidates_paths = []
installations = []
@@ -141,11 +153,11 @@ def find_java_installations(extra_install_patterns: list | None=None) -> list[di
{
"major": ver,
"raw": raw,
"homeDir": converted_path.parent.parent,
"executable": converted_path,
"homeDir": converted_path.parent.parent.as_posix(),
"executable": converted_path.as_posix(),
}
)
installations.sort(key=lambda item: item["major"], reverse=True)
return installations
return installations, errors
+2 -2
View File
@@ -308,8 +308,8 @@ def handle_runtime_dir_and_executable_process(dirs: list[Path], executables: lis
def download_java_runtimes(component: str, runtime_dir: Path, no_hash_check: bool = False,
progress_callback: Callable[[str, float], None] = None,
redownload_callback: Callable[[list[FileObject]], tuple[bool, list[FileObject]]] = None,
max_download_workers=RUNTIME_CHECK_MAX_WORKERS,
max_check_workers=RUNTIME_DOWNLOAD_MAX_WORKERS) -> None:
max_download_workers=RUNTIME_DOWNLOAD_MAX_WORKERS,
max_check_workers=RUNTIME_CHECK_MAX_WORKERS) -> None:
"""
Download runtime files from given component.
:param component: Target component of the java runtime (e.g. java-runtime-alpha, java-runtime-beta)