Skip to content

Commit

Permalink
feat: index java verisons
Browse files Browse the repository at this point in the history
Signed-off-by: Rachel Powers <[email protected]>
  • Loading branch information
Ryex committed Jun 17, 2023
1 parent cc881a8 commit 939233e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
23 changes: 21 additions & 2 deletions generateJava.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -398,17 +400,34 @@ 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(
uid = JAVA_COMPONENT,
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__":
Expand Down
2 changes: 1 addition & 1 deletion updateMojang.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 939233e

Please sign in to comment.