diff --git a/generateJava.py b/generateJava.py index 470146e..2b3f218 100644 --- a/generateJava.py +++ b/generateJava.py @@ -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 add_java_runtime(runtime: JavaRuntimeMeta, major: int, java_os: JavaRuntimeO 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 add_java_runtime(runtime: JavaRuntimeMeta, major: int, java_os: JavaRuntimeO 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__": diff --git a/updateMojang.py b/updateMojang.py index 03a77df..97b8f29 100755 --- a/updateMojang.py +++ b/updateMojang.py @@ -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