|
14 | 14 | import net.md_5.specialsource.provider.ClassLoaderProvider; |
15 | 15 | import net.md_5.specialsource.provider.JarProvider; |
16 | 16 | import net.md_5.specialsource.provider.JointProvider; |
| 17 | +import net.minecraftforge.gradle.common.BasePlugin; |
17 | 18 | import net.minecraftforge.gradle.common.Constants; |
18 | 19 | import net.minecraftforge.gradle.delayed.DelayedFile; |
19 | 20 | import net.minecraftforge.gradle.delayed.DelayedThingy; |
|
27 | 28 | import org.gradle.api.internal.artifacts.publish.AbstractPublishArtifact; |
28 | 29 | import org.gradle.api.tasks.bundling.AbstractArchiveTask; |
29 | 30 |
|
30 | | -import COM.rl.NameProvider; |
31 | | - |
32 | 31 | import com.google.common.base.Joiner; |
33 | 32 | import com.google.common.io.Files; |
34 | 33 |
|
@@ -306,7 +305,7 @@ public void setClasspath(FileCollection classpath) |
306 | 305 | * @throws IOException |
307 | 306 | * @throws org.gradle.api.InvalidUserDataException if the there is insufficient information available to generate the signature. |
308 | 307 | */ |
309 | | - void generate() throws IOException |
| 308 | + void generate() throws Exception |
310 | 309 | { |
311 | 310 | File toObf = getToObf(); |
312 | 311 | if (toObf == null) |
@@ -350,31 +349,45 @@ private void applySpecialSource(File input, File output, File srg) throws IOExce |
350 | 349 | remapper.remapJar(inputJar, output); |
351 | 350 | } |
352 | 351 |
|
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 |
354 | 354 | { |
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); |
357 | 360 |
|
358 | 361 | String[] args = new String[] { |
359 | 362 | "-notch", |
360 | 363 | cfg.getCanonicalPath() |
361 | 364 | }; |
362 | 365 |
|
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.. |
364 | 383 | } |
365 | 384 |
|
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 |
367 | 386 | { |
368 | | - String log = new File(caller.getTemporaryDir(), "retroguard.log").getCanonicalPath(); |
369 | | - File script = new File(caller.getTemporaryDir(), "retroguard.script"); |
370 | | - |
371 | 387 | // the config |
372 | 388 | String[] lines = new String[] { |
373 | | - "reobinput = "+in.getCanonicalPath(), |
374 | | - "reoboutput = "+out.getCanonicalPath(), |
375 | 389 | "reobf = "+srg.getCanonicalPath(), |
376 | 390 | "script = "+script.getCanonicalPath(), |
377 | | - "log = "+log, |
378 | 391 | "verbose = 0", |
379 | 392 | "quiet = 1", |
380 | 393 | "fullmap = 0", |
|
0 commit comments