Try and fix fernflower forking for the final time. Hopefully helps with #355

This commit is contained in:
modmuss50 2021-03-06 14:07:37 +00:00
parent 92efb9aa73
commit 5171c9bbde
6 changed files with 27 additions and 26 deletions

View file

@ -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");

View file

@ -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<? super JavaExecSpec> 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);
});
}

View file

@ -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"
}
}

View file

@ -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'
}
}

View file

@ -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'
}

View file

@ -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"
}