package io.gitlab.jfronny.glaunch.install.steps; import io.gitlab.jfronny.glaunch.GLaunch; import io.gitlab.jfronny.glaunch.install.SetupStepInfo; import io.gitlab.jfronny.glaunch.install.Step; import io.gitlab.jfronny.glaunch.model.Rules; import io.gitlab.jfronny.glaunch.model.VersionInfo; import io.gitlab.jfronny.glaunch.util.Utils; import java.io.IOException; public class DownloadLibrariesStep implements Step { @Override public void execute(SetupStepInfo info) throws IOException { //TODO feedback mainLoop: for (VersionInfo.Library library : info.version().libraries) { for (Rules rule : library.rules) { if (!rule.allow()) continue mainLoop; } if (library.classifiers != null) { downloadLib(switch (Utils.getOs()) { case "osx" -> library.classifiers.nativesMacos; case "windows" -> library.classifiers.nativesWindows; case "linux" -> library.classifiers.nativesLinux; default -> throw new RuntimeException("Not a valid OS"); }); } downloadLib(library.artifact); } } private void downloadLib(VersionInfo.Library.Artifact artifact) throws IOException { //TODO allow maven-like download for fabric Utils.downloadFile(artifact.url, artifact.sha1, GLaunch.LIBRARIES_DIR.resolve(artifact.path)); } }