From 4a530cd8b38fd23cd0508aa1cdd85240f75bbcf5 Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Fri, 4 Jun 2021 10:56:01 +0200 Subject: [PATCH] Get `setupDevWorkspace` working with Gradle 7 Unfortunately `setupDecompWorkspace` is broken because the decompiled code looks different from what the patches are expecting. And I quite frankly cannot be bothered to debug the horribly fragile mess that is Forge's decomp-patch-recomp pipeline. --- .../minecraftforge/gradle/tasks/CreateStartTask.java | 12 ++++++++++++ .../minecraftforge/gradle/tasks/DeobfuscateJar.java | 4 ++++ .../gradle/tasks/DownloadAssetsTask.java | 4 ++++ .../net/minecraftforge/gradle/tasks/GenSrgs.java | 6 +++--- .../minecraftforge/gradle/tasks/SplitJarTask.java | 3 ++- .../gradle/tasks/fernflower/ApplyFernFlowerTask.java | 4 ++++ .../minecraftforge/gradle/user/TaskRecompileMc.java | 3 +++ .../gradle/user/UserVanillaBasePlugin.java | 2 +- .../gradle/user/patcherUser/TaskApplyBinPatches.java | 12 ++++++------ 9 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/minecraftforge/gradle/tasks/CreateStartTask.java b/src/main/java/net/minecraftforge/gradle/tasks/CreateStartTask.java index d5845084f..5167c6420 100644 --- a/src/main/java/net/minecraftforge/gradle/tasks/CreateStartTask.java +++ b/src/main/java/net/minecraftforge/gradle/tasks/CreateStartTask.java @@ -213,6 +213,10 @@ private String getResource(URL resource) } } + public HashMap getResources() { + return resources; + } + /** * Use Resources.getResource() for this * @param resource URL of the resource in the jar @@ -238,11 +242,19 @@ public void addResource(String thing) this.addResource(thing, thing); } + public HashMap getReplacements() { + return replacements; + } + public void addReplacement(String token, Object replacement) { replacements.put(token, replacement); } + public List getExtraLines() { + return extraLines; + } + public void addExtraLine(String extra) { this.extraLines.add(extra); diff --git a/src/main/java/net/minecraftforge/gradle/tasks/DeobfuscateJar.java b/src/main/java/net/minecraftforge/gradle/tasks/DeobfuscateJar.java index 8591cbce5..df51cddde 100644 --- a/src/main/java/net/minecraftforge/gradle/tasks/DeobfuscateJar.java +++ b/src/main/java/net/minecraftforge/gradle/tasks/DeobfuscateJar.java @@ -40,6 +40,7 @@ import org.gradle.api.tasks.Input; import org.gradle.api.tasks.InputFile; import org.gradle.api.tasks.InputFiles; +import org.gradle.api.tasks.Internal; import org.gradle.api.tasks.Optional; import org.gradle.api.tasks.OutputFile; import org.gradle.api.tasks.TaskAction; @@ -388,6 +389,8 @@ public void setInJar(Object inJar) this.inJar = inJar; } + @Optional + @OutputFile public File getLog() { if (log == null) @@ -432,6 +435,7 @@ public void setOutJar(Object outJar) * Unlike getOutputJar() this method does not resolve the files. * @return Object that will resolve to */ + @Internal @SuppressWarnings("serial") public Closure getDelayedOutput() { diff --git a/src/main/java/net/minecraftforge/gradle/tasks/DownloadAssetsTask.java b/src/main/java/net/minecraftforge/gradle/tasks/DownloadAssetsTask.java index 1bdc35cef..e1cb5a970 100644 --- a/src/main/java/net/minecraftforge/gradle/tasks/DownloadAssetsTask.java +++ b/src/main/java/net/minecraftforge/gradle/tasks/DownloadAssetsTask.java @@ -41,6 +41,8 @@ import net.minecraftforge.gradle.util.json.version.AssetIndex.AssetEntry; import org.gradle.api.DefaultTask; +import org.gradle.api.tasks.InputFile; +import org.gradle.api.tasks.OutputDirectory; import org.gradle.api.tasks.TaskAction; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -98,6 +100,7 @@ public void doTask() throws IOException, InterruptedException } } + @OutputDirectory public File getAssetsDir() { return assetsDir.call(); @@ -108,6 +111,7 @@ public void setAssetsDir(DelayedFile assetsDir) this.assetsDir = assetsDir; } + @InputFile public File getAssetsIndex() { return getProject().file(assetIndex); diff --git a/src/main/java/net/minecraftforge/gradle/tasks/GenSrgs.java b/src/main/java/net/minecraftforge/gradle/tasks/GenSrgs.java index f1f7ccd01..72c23b700 100644 --- a/src/main/java/net/minecraftforge/gradle/tasks/GenSrgs.java +++ b/src/main/java/net/minecraftforge/gradle/tasks/GenSrgs.java @@ -64,7 +64,7 @@ public class GenSrgs extends CachedTask @Cached @OutputFile private DelayedFile notchToSrg; @Cached @OutputFile private DelayedFile notchToMcp; @Cached @OutputFile private DelayedFile mcpToNotch; - @Cached @OutputFile private DelayedFile SrgToMcp; + @Cached @OutputFile private DelayedFile srgToMcp; @Cached @OutputFile private DelayedFile mcpToSrg; @Cached @OutputFile private DelayedFile srgExc; @Cached @OutputFile private DelayedFile mcpExc; @@ -495,12 +495,12 @@ public void setNotchToMcp(DelayedFile deobfSrg) public File getSrgToMcp() { - return SrgToMcp.call(); + return srgToMcp.call(); } public void setSrgToMcp(DelayedFile deobfSrg) { - this.SrgToMcp = deobfSrg; + this.srgToMcp = deobfSrg; } public File getMcpToSrg() diff --git a/src/main/java/net/minecraftforge/gradle/tasks/SplitJarTask.java b/src/main/java/net/minecraftforge/gradle/tasks/SplitJarTask.java index cc08e8015..05202c75d 100644 --- a/src/main/java/net/minecraftforge/gradle/tasks/SplitJarTask.java +++ b/src/main/java/net/minecraftforge/gradle/tasks/SplitJarTask.java @@ -47,7 +47,6 @@ public class SplitJarTask extends CachedTask implements PatternFilterable @InputFile private Object inJar; - @Input private PatternSet pattern = new PatternSet(); @Cached @@ -171,12 +170,14 @@ public PatternFilterable exclude(Closure arg0) return pattern.exclude(arg0); } + @Input @Override public Set getExcludes() { return pattern.getExcludes(); } + @Input @Override public Set getIncludes() { diff --git a/src/main/java/net/minecraftforge/gradle/tasks/fernflower/ApplyFernFlowerTask.java b/src/main/java/net/minecraftforge/gradle/tasks/fernflower/ApplyFernFlowerTask.java index ff0f5e7c2..7c3485f2e 100644 --- a/src/main/java/net/minecraftforge/gradle/tasks/fernflower/ApplyFernFlowerTask.java +++ b/src/main/java/net/minecraftforge/gradle/tasks/fernflower/ApplyFernFlowerTask.java @@ -27,7 +27,9 @@ import org.codehaus.groovy.runtime.ResourceGroovyMethods; import org.gradle.api.Action; import org.gradle.api.file.FileCollection; +import org.gradle.api.tasks.Input; import org.gradle.api.tasks.InputFile; +import org.gradle.api.tasks.InputFiles; import org.gradle.api.tasks.OutputFile; import org.gradle.api.tasks.TaskAction; import org.gradle.process.ExecResult; @@ -168,6 +170,7 @@ public void setOutJar(Object outJar) this.outJar = outJar; } + @InputFiles public FileCollection getClasspath() { return classpath; @@ -178,6 +181,7 @@ public void setClasspath(FileCollection classpath) this.classpath = classpath; } + @InputFiles public FileCollection getForkedClasspath() { return forkedClasspath; diff --git a/src/main/java/net/minecraftforge/gradle/user/TaskRecompileMc.java b/src/main/java/net/minecraftforge/gradle/user/TaskRecompileMc.java index dd53534f7..bdf1800d0 100644 --- a/src/main/java/net/minecraftforge/gradle/user/TaskRecompileMc.java +++ b/src/main/java/net/minecraftforge/gradle/user/TaskRecompileMc.java @@ -103,6 +103,9 @@ public void doStuff() throws IOException private static String getExtPath() { String currentExtDirs = System.getProperty("java.ext.dirs"); + if (currentExtDirs == null) { + return null; + } String newExtDirs = ""; String[] parts = currentExtDirs.split(File.pathSeparator); if (parts.length > 0) { diff --git a/src/main/java/net/minecraftforge/gradle/user/UserVanillaBasePlugin.java b/src/main/java/net/minecraftforge/gradle/user/UserVanillaBasePlugin.java index d033e9354..564ff63c7 100644 --- a/src/main/java/net/minecraftforge/gradle/user/UserVanillaBasePlugin.java +++ b/src/main/java/net/minecraftforge/gradle/user/UserVanillaBasePlugin.java @@ -49,7 +49,7 @@ protected final void applyUserPlugin() createDecompTasks(CLEAN_ROOT + jarName + "/" + REPLACE_MC_VERSION + "/" + MCP_INSERT + "/" + jarName + cleanSuffix, DIR_LOCAL_CACHE + "/" + jarName + dirtySuffix); // remove the unused merge jars task - project.getTasks().remove(project.getTasks().getByName(TASK_MERGE_JARS)); + project.getTasks().getByName(TASK_MERGE_JARS).setEnabled(false); // add version json task to CI and dev workspace tasks project.getTasks().getByName(TASK_SETUP_CI).dependsOn(Constants.TASK_DL_VERSION_JSON); diff --git a/src/main/java/net/minecraftforge/gradle/user/patcherUser/TaskApplyBinPatches.java b/src/main/java/net/minecraftforge/gradle/user/patcherUser/TaskApplyBinPatches.java index e8a393dc9..04d7cbbe8 100644 --- a/src/main/java/net/minecraftforge/gradle/user/patcherUser/TaskApplyBinPatches.java +++ b/src/main/java/net/minecraftforge/gradle/user/patcherUser/TaskApplyBinPatches.java @@ -61,8 +61,8 @@ public class TaskApplyBinPatches extends CachedTask { //@formatter:off @InputFile Object inJar; - @InputFile Object classesJar; - @InputFile Object resourcesJar; + @InputFile Object classJar; + @InputFile Object resourceJar; @InputFile Object patches; //@formatter:on @@ -285,22 +285,22 @@ public void setPatches(Object patchesJar) public File getClassJar() { - return getProject().file(classesJar); + return getProject().file(classJar); } public void setClassJar(Object extraJar) { - this.classesJar = extraJar; + this.classJar = extraJar; } public File getResourceJar() { - return getProject().file(resourcesJar); + return getProject().file(resourceJar); } public void setResourceJar(Object resources) { - this.resourcesJar = resources; + this.resourceJar = resources; } public static class ClassPatch