Skip to content

Commit 13475c9

Browse files
committed
fixed retroguard reobfuscation
1 parent b1c92db commit 13475c9

File tree

2 files changed

+29
-16
lines changed

2 files changed

+29
-16
lines changed

src/main/java/net/minecraftforge/gradle/tasks/user/reobf/ObfArtifact.java

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import net.md_5.specialsource.provider.ClassLoaderProvider;
1515
import net.md_5.specialsource.provider.JarProvider;
1616
import net.md_5.specialsource.provider.JointProvider;
17+
import net.minecraftforge.gradle.common.BasePlugin;
1718
import net.minecraftforge.gradle.common.Constants;
1819
import net.minecraftforge.gradle.delayed.DelayedFile;
1920
import net.minecraftforge.gradle.delayed.DelayedThingy;
@@ -27,8 +28,6 @@
2728
import org.gradle.api.internal.artifacts.publish.AbstractPublishArtifact;
2829
import org.gradle.api.tasks.bundling.AbstractArchiveTask;
2930

30-
import COM.rl.NameProvider;
31-
3231
import com.google.common.base.Joiner;
3332
import com.google.common.io.Files;
3433

@@ -306,7 +305,7 @@ public void setClasspath(FileCollection classpath)
306305
* @throws IOException
307306
* @throws org.gradle.api.InvalidUserDataException if the there is insufficient information available to generate the signature.
308307
*/
309-
void generate() throws IOException
308+
void generate() throws Exception
310309
{
311310
File toObf = getToObf();
312311
if (toObf == null)
@@ -350,31 +349,45 @@ private void applySpecialSource(File input, File output, File srg) throws IOExce
350349
remapper.remapJar(inputJar, output);
351350
}
352351

353-
private void applyRetroGuard(File input, File output, File srg) throws IOException
352+
@SuppressWarnings({ "rawtypes", "unchecked", "static-access" })
353+
private void applyRetroGuard(File input, File output, File srg) throws Exception
354354
{
355-
File cfg = new File(caller.getTemporaryDir(), "retroguard.cfg");
356-
generateRgConfig(cfg, input, output, srg);
355+
File cfg = new File(caller.getTemporaryDir(), "retroguard.cfg");
356+
File log = new File(caller.getTemporaryDir(), "retroguard.log");
357+
File script = new File(caller.getTemporaryDir(), "retroguard.script");
358+
359+
generateRgConfig(cfg, script, srg);
357360

358361
String[] args = new String[] {
359362
"-notch",
360363
cfg.getCanonicalPath()
361364
};
362365

363-
NameProvider.parseCommandLine(args);
366+
// load in classpath... ewww
367+
ClassLoader loader = BasePlugin.class.getClassLoader(); // dunno.. maybe this will load the classes??
368+
if (classpath != null)
369+
{
370+
loader = new URLClassLoader(ObfuscateTask.toUrls(classpath), BasePlugin.class.getClassLoader());
371+
}
372+
373+
// the name provider
374+
Class clazz = getClass().forName("COM.rl.NameProvider", true, loader);
375+
clazz.getMethod("parseCommandLine", String[].class).invoke(null, new Object[] { args });
376+
377+
// actual retroguard
378+
clazz = getClass().forName("COM.rl.obf.RetroGuardImpl", true, loader);
379+
clazz.getMethod("obfuscate", File.class, File.class, File.class, File.class).invoke(null, input, output, script, log);
380+
381+
loader = null; // if we are lucky.. this will be dropped...
382+
System.gc(); // clean anything out.. I hope..
364383
}
365384

366-
private void generateRgConfig(File config, File in, File out, File srg) throws IOException
385+
private void generateRgConfig(File config, File script, File srg) throws IOException
367386
{
368-
String log = new File(caller.getTemporaryDir(), "retroguard.log").getCanonicalPath();
369-
File script = new File(caller.getTemporaryDir(), "retroguard.script");
370-
371387
// the config
372388
String[] lines = new String[] {
373-
"reobinput = "+in.getCanonicalPath(),
374-
"reoboutput = "+out.getCanonicalPath(),
375389
"reobf = "+srg.getCanonicalPath(),
376390
"script = "+script.getCanonicalPath(),
377-
"log = "+log,
378391
"verbose = 0",
379392
"quiet = 1",
380393
"fullmap = 0",

src/main/java/net/minecraftforge/gradle/tasks/user/reobf/ReobfTask.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ public void execute(PublishArtifact artifact)
216216

217217
/**
218218
* Generates the signature files.
219-
* @throws IOException
219+
* @throws Exception
220220
*/
221221
@TaskAction
222-
public void generate() throws IOException
222+
public void generate() throws Exception
223223
{
224224
for (ObfArtifact obf : getObfuscated())
225225
obf.generate();

0 commit comments

Comments
 (0)