feat: index java verisons

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
Rachel Powers 2023-06-16 22:40:54 -07:00
parent cc881a82d8
commit 939233e42c
No known key found for this signature in database
GPG Key ID: E10E321EB160949B
2 changed files with 22 additions and 3 deletions

View File

@ -1,6 +1,8 @@
import copy
import datetime
import os
from typing import Optional
from functools import reduce
from meta.common import ensure_component_dir, launcher_path, upstream_path, static_path
@ -398,9 +400,26 @@ def main():
if rec is not None:
print(f"Recomending {rec.name} for Java {major} {java_os}")
def newest_timestamp(a: datetime.datetime | None, b: datetime.datetime):
if a is None or a < b:
return b
return a
version_file = os.path.join(
LAUNCHER_DIR, JAVA_COMPONENT, f"java{major}.json")
java_version = JavaRuntimeVersion(name = f"Java {major}", uid = JAVA_COMPONENT, version = f"java{major}", runtimes = runtimes)
java_version = JavaRuntimeVersion(
name = f"Java {major}",
uid = JAVA_COMPONENT,
version = f"java{major}",
releaseTime=reduce(
newest_timestamp,
(runtime.release_time
for _, runtime_list in runtimes
for runtime in runtime_list
),
None
),
runtimes = runtimes)
java_version.write(version_file)
package = MetaPackage(
@ -408,7 +427,7 @@ def main():
name = "Java Runtimes",
recommended = ["java8", "java17"]
)
package.write(os.path.josn(LAUNCHER_DIR, JAVA_COMPONENT, "package.json"))
package.write(os.path.join(LAUNCHER_DIR, JAVA_COMPONENT, "package.json"))
if __name__ == "__main__":

View File

@ -130,7 +130,7 @@ def main():
"Updating "
+ version.id
+ " to timestamp "
+ version.release_time.strftime("%s")
+ version.release_time.isoformat()
)
fetch_version(
os.path.join(UPSTREAM_DIR, VERSIONS_DIR, f"{x}.json"), version.url