diff options
author | modmuss50 <modmuss50@gmail.com> | 2020-12-30 20:34:34 +0000 |
---|---|---|
committer | modmuss50 <modmuss50@gmail.com> | 2020-12-30 20:34:34 +0000 |
commit | 11b62989e7887912542e633302bd6e693832790f (patch) | |
tree | 4bdbd072fb6e2d74fcc0921dcb02d7d0040c1183 /src/main/java/net/fabricmc/loom | |
parent | 841fc5a4dbbb713e7698f45e74104334caa4ba01 (diff) | |
download | architectury-loom-11b62989e7887912542e633302bd6e693832790f.tar.gz architectury-loom-11b62989e7887912542e633302bd6e693832790f.tar.bz2 architectury-loom-11b62989e7887912542e633302bd6e693832790f.zip |
Cleanup output files when remap fails. Fixes #321
Diffstat (limited to 'src/main/java/net/fabricmc/loom')
-rw-r--r-- | src/main/java/net/fabricmc/loom/build/ModCompileRemapper.java | 11 | ||||
-rw-r--r-- | src/main/java/net/fabricmc/loom/util/SourceRemapper.java | 7 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/main/java/net/fabricmc/loom/build/ModCompileRemapper.java b/src/main/java/net/fabricmc/loom/build/ModCompileRemapper.java index 8fe879a4..c257a69d 100644 --- a/src/main/java/net/fabricmc/loom/build/ModCompileRemapper.java +++ b/src/main/java/net/fabricmc/loom/build/ModCompileRemapper.java @@ -107,6 +107,8 @@ public class ModCompileRemapper { try { ModProcessor.processMods(project, modDependencies); } catch (IOException e) { + // Failed to remap, lets clean up to ensure we try again next time + modDependencies.forEach(info -> info.getRemappedOutput().delete()); throw new RuntimeException("Failed to remap mods", e); } @@ -170,14 +172,7 @@ public class ModCompileRemapper { boolean refreshDeps = project.getGradle().getStartParameter().isRefreshDependencies(); if (!remappedSources.exists() || sources.lastModified() <= 0 || sources.lastModified() > remappedSources.lastModified() || refreshDeps) { - try { - sourceRemapper.scheduleRemapSources(sources, remappedSources, false, true); // Depenedency sources are used in ide only so don't need to be reproducable - - // Set the remapped sources creation date to match the sources if we're likely succeeded in making it - remappedSources.setLastModified(sources.lastModified()); - } catch (Exception e) { - e.printStackTrace(); - } + sourceRemapper.scheduleRemapSources(sources, remappedSources, false, true); // Depenedency sources are used in ide only so don't need to be reproducable } else { project.getLogger().info(remappedSources.getName() + " is up to date with " + sources.getName()); } diff --git a/src/main/java/net/fabricmc/loom/util/SourceRemapper.java b/src/main/java/net/fabricmc/loom/util/SourceRemapper.java index e7a5bef6..46642254 100644 --- a/src/main/java/net/fabricmc/loom/util/SourceRemapper.java +++ b/src/main/java/net/fabricmc/loom/util/SourceRemapper.java @@ -72,13 +72,18 @@ public class SourceRemapper { scheduleRemapSources(source, destination, false, true); // Not reproducable by default, old behavior } - public void scheduleRemapSources(File source, File destination, boolean reproducibleFileOrder, boolean preserveFileTimestamps) throws Exception { + public void scheduleRemapSources(File source, File destination, boolean reproducibleFileOrder, boolean preserveFileTimestamps) { remapTasks.add((logger) -> { try { logger.progress("remapping sources - " + source.getName()); remapSourcesInner(source, destination); ZipReprocessorUtil.reprocessZip(destination, reproducibleFileOrder, preserveFileTimestamps); + + // Set the remapped sources creation date to match the sources if we're likely succeeded in making it + destination.setLastModified(source.lastModified()); } catch (Exception e) { + // Failed to remap, lets clean up to ensure we try again next time + destination.delete(); throw new RuntimeException("Failed to remap sources for " + source, e); } }); |