Skip to content

Commit 0636bbd

Browse files
fix(release): accept Temurin jmod archives without a jmods directory
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent c8ea4d9 commit 0636bbd

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

‎scripts/prepare_jdks.py‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,23 @@ def download_file(url: str, destination: Path) -> None:
172172

173173

174174
def locate_jmods_dir(root: Path) -> Path:
175-
candidates = [
175+
named = [
176176
directory
177177
for directory in root.rglob("jmods")
178178
if directory.is_dir() and any(directory.glob("*.jmod"))
179179
]
180-
if not candidates:
181-
raise RuntimeError(f"Could not locate a jmods directory under {root}")
182-
return sorted(candidates, key=lambda item: (len(item.relative_to(root).parts), str(item)))[0]
180+
if named:
181+
return sorted(named, key=lambda item: (len(item.relative_to(root).parts), str(item)))[0]
182+
183+
parents = {
184+
jmod.parent
185+
for jmod in root.rglob("*.jmod")
186+
if jmod.is_file()
187+
}
188+
if not parents:
189+
sample = ", ".join(str(path.relative_to(root)) for path in list(root.rglob("*"))[:8])
190+
raise RuntimeError(f"Could not locate a jmods directory under {root}. Entries: {sample or '<empty>'}")
191+
return sorted(parents, key=lambda item: (len(item.relative_to(root).parts), str(item)))[0]
183192

184193

185194
def locate_java_home(root: Path) -> Path:

‎scripts/test_prepare_jdks.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ def test_locate_jmods_dir_for_nested_and_macos_layouts(self) -> None:
102102
(macos / "java.base.jmod").write_bytes(b"jmod")
103103
self.assertEqual(locate_jmods_dir(root / "temurin-25.jdk"), macos)
104104

105+
flat = root / "flat" / "jdk-25.0.4.1+1"
106+
flat.mkdir(parents=True)
107+
(flat / "java.base.jmod").write_bytes(b"jmod")
108+
self.assertEqual(locate_jmods_dir(root / "flat"), flat)
109+
105110
def test_install_jmods_from_tar_and_zip(self) -> None:
106111
with tempfile.TemporaryDirectory() as tmp_dir:
107112
root = Path(tmp_dir)
@@ -137,7 +142,7 @@ def write_archive(url: str, destination: Path) -> None:
137142
destination.parent.mkdir(parents=True, exist_ok=True)
138143
payload = b"jmod"
139144
with tarfile.open(destination, "w:gz") as archive:
140-
info = tarfile.TarInfo("jdk-25/jmods/java.base.jmod")
145+
info = tarfile.TarInfo("jdk-25.0.4.1+1/java.base.jmod")
141146
info.size = len(payload)
142147
archive.addfile(info, io.BytesIO(payload))
143148

0 commit comments

Comments
 (0)