Skip to content

Commit c928fb1

Browse files
author
Trong Nhan Mai
committed
chore: remove extra comments feature and some refactoring to simplify the generation of reproducible central build spec
1 parent 68c4a6d commit c928fb1

File tree

4 files changed

+346
-375
lines changed

4 files changed

+346
-375
lines changed

src/macaron/build_spec_generator/jdk_finder.py

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ class JavaArtifactExt(str, Enum):
2525
JAR = ".jar"
2626

2727

28+
class CacheStrategy(Enum):
29+
"""The strategy for caching the downloaded artifacts for JDK version finding."""
30+
31+
DISABLE = 0
32+
MAVEN_LAYOUT = 1
33+
34+
2835
def download_file(url: str, dest: str) -> None:
2936
"""Stream a file into a local destination.
3037
@@ -213,7 +220,7 @@ def find_jdk_version_from_remote_maven_repo_cache(
213220
"""Return the jdk version string from an artifact matching a given GAV from a remote maven layout repository.
214221
215222
This function cache the downloaded artifact in a maven layout https://maven.apache.org/repository/layout.html
216-
undert ``local_cache_repo``.
223+
under ``local_cache_repo``.
217224
We assume that the remote maven layout repository supports downloading a file through a HTTPS URL.
218225
219226
Parameters
@@ -286,7 +293,7 @@ def find_jdk_version_from_central_maven_repo(
286293
group_id: str,
287294
artifact_id: str,
288295
version: str,
289-
use_cache: bool = True,
296+
cache_strat: CacheStrategy = CacheStrategy.MAVEN_LAYOUT,
290297
) -> str | None:
291298
"""Return the jdk version string from an artifact matching a given GAV from Maven Central repository.
292299
@@ -302,11 +309,8 @@ def find_jdk_version_from_central_maven_repo(
302309
The artifact ID part of the GAV coordinate.
303310
version: str
304311
The version part of the GAV coordinate.
305-
remote_maven_repo_url: str
306-
The URL to the remote maven layout repository.
307-
local_cache_repo: str
308-
The path to a local directory for caching the downloaded artifact used in JDK version
309-
extraction.
312+
cache_strat: CacheStrategy
313+
Specify how artifacts from maven central are persisted.
310314
311315
Returns
312316
-------
@@ -321,20 +325,21 @@ def find_jdk_version_from_central_maven_repo(
321325
)
322326
asset_name = f"{artifact_id}-{version}{JavaArtifactExt.JAR.value}"
323327

324-
if use_cache:
325-
return find_jdk_version_from_remote_maven_repo_cache(
326-
group_id=group_id,
327-
artifact_id=artifact_id,
328-
version=version,
329-
asset_name=asset_name,
330-
remote_maven_repo_url=central_repo_url,
331-
local_cache_repo=local_cache_maven_repo,
332-
)
333-
334-
return find_jdk_version_from_remote_maven_repo_standalone(
335-
group_id=group_id,
336-
artifact_id=artifact_id,
337-
version=version,
338-
asset_name=asset_name,
339-
remote_maven_repo_url=central_repo_url,
340-
)
328+
match cache_strat:
329+
case CacheStrategy.MAVEN_LAYOUT:
330+
return find_jdk_version_from_remote_maven_repo_cache(
331+
group_id=group_id,
332+
artifact_id=artifact_id,
333+
version=version,
334+
asset_name=asset_name,
335+
remote_maven_repo_url=central_repo_url,
336+
local_cache_repo=local_cache_maven_repo,
337+
)
338+
case CacheStrategy.DISABLE:
339+
return find_jdk_version_from_remote_maven_repo_standalone(
340+
group_id=group_id,
341+
artifact_id=artifact_id,
342+
version=version,
343+
asset_name=asset_name,
344+
remote_maven_repo_url=central_repo_url,
345+
)

src/macaron/build_spec_generator/reproducible_central/rc_build_info.py

Lines changed: 0 additions & 146 deletions
This file was deleted.

0 commit comments

Comments
 (0)