Skip to content

Commit

Permalink
Get setupDevWorkspace working with Gradle 7
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Johni0702 committed Jun 4, 2021
1 parent 78aded6 commit 4a530cd
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 11 deletions.
12 changes: 12 additions & 0 deletions src/main/java/net/minecraftforge/gradle/tasks/CreateStartTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ private String getResource(URL resource)
}
}

public HashMap<String, String> getResources() {
return resources;
}

/**
* Use Resources.getResource() for this
* @param resource URL of the resource in the jar
Expand All @@ -238,11 +242,19 @@ public void addResource(String thing)
this.addResource(thing, thing);
}

public HashMap<String, Object> getReplacements() {
return replacements;
}

public void addReplacement(String token, Object replacement)
{
replacements.put(token, replacement);
}

public List<String> getExtraLines() {
return extraLines;
}

public void addExtraLine(String extra)
{
this.extraLines.add(extra);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -388,6 +389,8 @@ public void setInJar(Object inJar)
this.inJar = inJar;
}

@Optional
@OutputFile
public File getLog()
{
if (log == null)
Expand Down Expand Up @@ -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<File> getDelayedOutput()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -98,6 +100,7 @@ public void doTask() throws IOException, InterruptedException
}
}

@OutputDirectory
public File getAssetsDir()
{
return assetsDir.call();
Expand All @@ -108,6 +111,7 @@ public void setAssetsDir(DelayedFile assetsDir)
this.assetsDir = assetsDir;
}

@InputFile
public File getAssetsIndex()
{
return getProject().file(assetIndex);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/minecraftforge/gradle/tasks/GenSrgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public class SplitJarTask extends CachedTask implements PatternFilterable
@InputFile
private Object inJar;

@Input
private PatternSet pattern = new PatternSet();

@Cached
Expand Down Expand Up @@ -171,12 +170,14 @@ public PatternFilterable exclude(Closure arg0)
return pattern.exclude(arg0);
}

@Input
@Override
public Set<String> getExcludes()
{
return pattern.getExcludes();
}

@Input
@Override
public Set<String> getIncludes()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -168,6 +170,7 @@ public void setOutJar(Object outJar)
this.outJar = outJar;
}

@InputFiles
public FileCollection getClasspath()
{
return classpath;
Expand All @@ -178,6 +181,7 @@ public void setClasspath(FileCollection classpath)
this.classpath = classpath;
}

@InputFiles
public FileCollection getForkedClasspath()
{
return forkedClasspath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4a530cd

Please sign in to comment.