From d6cd21d6b6786a409ddae9975131e9335042829c Mon Sep 17 00:00:00 2001 From: supersaiyansubtlety Date: Tue, 26 Nov 2024 22:15:37 -0800 Subject: [PATCH] fix DownloadTargetMetaFileTask when meta file is unavailable --- .../task/diff/DownloadTargetMetaFileTask.java | 19 +++++++++++++++++-- .../quilt/internal/util/DownloadUtil.java | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/java/quilt/internal/task/diff/DownloadTargetMetaFileTask.java b/buildSrc/src/main/java/quilt/internal/task/diff/DownloadTargetMetaFileTask.java index 7a03aa7a5e..5edaf01efb 100644 --- a/buildSrc/src/main/java/quilt/internal/task/diff/DownloadTargetMetaFileTask.java +++ b/buildSrc/src/main/java/quilt/internal/task/diff/DownloadTargetMetaFileTask.java @@ -12,6 +12,7 @@ import quilt.internal.plugin.TargetDiffPlugin; import quilt.internal.task.SimpleDownloadTask; +import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.util.Comparator; @@ -31,10 +32,15 @@ public abstract class DownloadTargetMetaFileTask extends SimpleDownloadTask { public abstract Property getMinecraftVersion(); public Provider provideTargetVersion() { - return this.getDest().map(metaFile -> { + return this.getDest().map(metaDest -> { final JsonElement parsed; try { - parsed = JsonParser.parseReader(new FileReader(metaFile.getAsFile())); + final File metaFile = metaDest.getAsFile(); + if (!metaFile.exists()) { + return null; + } + + parsed = JsonParser.parseReader(new FileReader(metaFile)); } catch (FileNotFoundException e) { throw new GradleException("Failed to open meta file", e); } @@ -56,4 +62,13 @@ public DownloadTargetMetaFileTask() { this.getMinecraftVersion().map(version -> "https://meta.quiltmc.org/v3/versions/quilt-mappings/" + version) ); } + + @Override + public void download() { + try { + super.download(); + } catch (GradleException e) { + this.getLogger().lifecycle(":target meta file unavailable"); + } + } } diff --git a/buildSrc/src/main/java/quilt/internal/util/DownloadUtil.java b/buildSrc/src/main/java/quilt/internal/util/DownloadUtil.java index 1466cc6c42..8da5af4bec 100644 --- a/buildSrc/src/main/java/quilt/internal/util/DownloadUtil.java +++ b/buildSrc/src/main/java/quilt/internal/util/DownloadUtil.java @@ -27,7 +27,7 @@ public static boolean download(String url, File dest, boolean overwrite, @Nullab """ Failed to download: \tfrom: %s - \tto: %s + \tto: %s\ """.formatted(url, dest), e );