diff --git a/src/main/java/net/fabricmc/loom/decompilers/fernflower/AbstractFernFlowerDecompiler.java b/src/main/java/net/fabricmc/loom/decompilers/fernflower/AbstractFernFlowerDecompiler.java index 61dbaf0..ecc1386 100644 --- a/src/main/java/net/fabricmc/loom/decompilers/fernflower/AbstractFernFlowerDecompiler.java +++ b/src/main/java/net/fabricmc/loom/decompilers/fernflower/AbstractFernFlowerDecompiler.java @@ -100,7 +100,7 @@ public abstract class AbstractFernFlowerDecompiler implements LoomDecompiler { progressGroup.started(); ExecResult result = ForkingJavaExec.javaexec( - project.getRootProject().getPlugins().hasPlugin("fabric-loom") ? project.getRootProject() : project, + project, spec -> { spec.setMain(fernFlowerExecutor().getName()); spec.jvmArgs("-Xms200m", "-Xmx3G"); diff --git a/src/main/java/net/fabricmc/loom/decompilers/fernflower/ForkingJavaExec.java b/src/main/java/net/fabricmc/loom/decompilers/fernflower/ForkingJavaExec.java index 8b5f5f6..b62784f 100644 --- a/src/main/java/net/fabricmc/loom/decompilers/fernflower/ForkingJavaExec.java +++ b/src/main/java/net/fabricmc/loom/decompilers/fernflower/ForkingJavaExec.java @@ -24,11 +24,10 @@ package net.fabricmc.loom.decompilers.fernflower; +import java.net.URLClassLoader; + import org.gradle.api.Action; import org.gradle.api.Project; -import org.gradle.api.artifacts.ConfigurationContainer; -import org.gradle.api.artifacts.dsl.DependencyHandler; -import org.gradle.api.file.FileCollection; import org.gradle.process.ExecResult; import org.gradle.process.JavaExecSpec; @@ -40,13 +39,8 @@ import org.gradle.process.JavaExecSpec; */ public class ForkingJavaExec { public static ExecResult javaexec(Project project, Action action) { - ConfigurationContainer configurations = project.getBuildscript().getConfigurations(); - DependencyHandler handler = project.getDependencies(); - FileCollection classpath = configurations.getByName("classpath")// - .plus(configurations.detachedConfiguration(handler.localGroovy())); - return project.javaexec(spec -> { - spec.classpath(classpath); + spec.classpath((Object[]) ((URLClassLoader) ForkingJavaExec.class.getClassLoader()).getURLs()); action.execute(spec); }); } diff --git a/src/test/groovy/net/fabricmc/loom/DecompileTest.groovy b/src/test/groovy/net/fabricmc/loom/DecompileTest.groovy index b30f90a..c0e5ea6 100644 --- a/src/test/groovy/net/fabricmc/loom/DecompileTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/DecompileTest.groovy @@ -25,30 +25,30 @@ package net.fabricmc.loom import net.fabricmc.loom.util.ProjectTestTrait -import spock.lang.Ignore import spock.lang.Specification import spock.lang.Unroll import static org.gradle.testkit.runner.TaskOutcome.SUCCESS -@Ignore // TODO this fails due to the plugin classpath being setup differently. We need to explore other ways to do this. class DecompileTest extends Specification implements ProjectTestTrait { @Override String name() { - "simple" + "decompile" } @Unroll - def "#decompiler decompile"() { + def "#decompiler gradle #gradle"() { when: - def result = create(task) + def result = create(task, gradle) then: result.task(":${task}").outcome == SUCCESS where: - decompiler | task - 'fernflower' | "genSources" - 'cfr' | "genSourcesWithExperimentalCfr" + decompiler | task | gradle + 'fernflower' | "genSources" | "6.8.3" + 'fernflower' | "genSources" | "4.9" + 'fernflower' | "genSources" | "7.0-milestone-2" + 'cfr' | "genSourcesWithExperimentalCfr" | "6.8.3" } } diff --git a/src/test/groovy/net/fabricmc/loom/LegacyProjectTest.groovy b/src/test/groovy/net/fabricmc/loom/LegacyProjectTest.groovy index aac95fe..8d837a6 100644 --- a/src/test/groovy/net/fabricmc/loom/LegacyProjectTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/LegacyProjectTest.groovy @@ -44,10 +44,4 @@ class LegacyProjectTest extends Specification implements ProjectTestTrait { then: result.task(":build").outcome == SUCCESS } - - @Override - String warningMode() { - // Gradle 4.9 doesnt support fail, and well this is a legacy test so deprecations are expected - 'all' - } } diff --git a/src/test/groovy/net/fabricmc/loom/util/ProjectTestTrait.groovy b/src/test/groovy/net/fabricmc/loom/util/ProjectTestTrait.groovy index c543ece..b47622e 100644 --- a/src/test/groovy/net/fabricmc/loom/util/ProjectTestTrait.groovy +++ b/src/test/groovy/net/fabricmc/loom/util/ProjectTestTrait.groovy @@ -75,7 +75,7 @@ trait ProjectTestTrait { BuildResult create(String task, String gradleVersion = "6.8.3") { GradleRunner.create() .withProjectDir(testProjectDir) - .withArguments(task, "--stacktrace", "--warning-mode", warningMode(), "--gradle-user-home", gradleHomeDirectory(gradleVersion)) + .withArguments(task, "--stacktrace", "--warning-mode", warningMode(gradleVersion), "--gradle-user-home", gradleHomeDirectory(gradleVersion)) .withPluginClasspath() .withGradleVersion(gradleVersion) .forwardOutput() @@ -83,7 +83,11 @@ trait ProjectTestTrait { .build() } - String warningMode() { + String warningMode(String gradleVersion) { + if (gradleVersion == "4.9") { + return "all" + } + System.getenv().TEST_WARNING_MODE ?: 'all' } diff --git a/src/test/resources/projects/decompile/build.gradle b/src/test/resources/projects/decompile/build.gradle new file mode 100644 index 0000000..daa90b1 --- /dev/null +++ b/src/test/resources/projects/decompile/build.gradle @@ -0,0 +1,9 @@ +plugins { + id 'fabric-loom' +} + +dependencies { + minecraft "com.mojang:minecraft:1.16.5" + mappings "net.fabricmc:yarn:1.16.5+build.5:v2" + modImplementation "net.fabricmc:fabric-loader:0.11.2" +}