Cleanup output files when remap fails. Fixes #321
parent
841fc5a4db
commit
11b62989e7
|
@ -107,6 +107,8 @@ public class ModCompileRemapper {
|
||||||
try {
|
try {
|
||||||
ModProcessor.processMods(project, modDependencies);
|
ModProcessor.processMods(project, modDependencies);
|
||||||
} catch (IOException e) {
|
} 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);
|
throw new RuntimeException("Failed to remap mods", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,14 +172,7 @@ public class ModCompileRemapper {
|
||||||
boolean refreshDeps = project.getGradle().getStartParameter().isRefreshDependencies();
|
boolean refreshDeps = project.getGradle().getStartParameter().isRefreshDependencies();
|
||||||
|
|
||||||
if (!remappedSources.exists() || sources.lastModified() <= 0 || sources.lastModified() > remappedSources.lastModified() || refreshDeps) {
|
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
|
||||||
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();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
project.getLogger().info(remappedSources.getName() + " is up to date with " + sources.getName());
|
project.getLogger().info(remappedSources.getName() + " is up to date with " + sources.getName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,13 +72,18 @@ public class SourceRemapper {
|
||||||
scheduleRemapSources(source, destination, false, true); // Not reproducable by default, old behavior
|
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) -> {
|
remapTasks.add((logger) -> {
|
||||||
try {
|
try {
|
||||||
logger.progress("remapping sources - " + source.getName());
|
logger.progress("remapping sources - " + source.getName());
|
||||||
remapSourcesInner(source, destination);
|
remapSourcesInner(source, destination);
|
||||||
ZipReprocessorUtil.reprocessZip(destination, reproducibleFileOrder, preserveFileTimestamps);
|
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) {
|
} 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);
|
throw new RuntimeException("Failed to remap sources for " + source, e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue