Revert some of the changes to genSource's.

More work is needed to fix all the issues with it but its not really something I want to get into right now.
This commit is contained in:
modmuss50 2021-03-23 19:08:15 +00:00
parent c02f436123
commit 43a6b0f65f
2 changed files with 26 additions and 1 deletions

View file

@ -24,10 +24,14 @@
package net.fabricmc.loom.decompilers.fernflower;
import java.net.URL;
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,8 +44,27 @@ import org.gradle.process.JavaExecSpec;
public class ForkingJavaExec {
public static ExecResult javaexec(Project project, Action<? super JavaExecSpec> action) {
return project.javaexec(spec -> {
spec.classpath((Object[]) ((URLClassLoader) ForkingJavaExec.class.getClassLoader()).getURLs());
spec.classpath(getClasspath(project));
action.execute(spec);
});
}
private static Object getClasspath(Project project) {
if (System.getProperty("fabric.loom.test") != null) {
return getTestClasspath();
}
return getRuntimeClasspath(project.getRootProject().getPlugins().hasPlugin("fabric-loom") ? project.getRootProject() : project);
}
private static FileCollection getRuntimeClasspath(Project project) {
ConfigurationContainer configurations = project.getBuildscript().getConfigurations();
DependencyHandler handler = project.getDependencies();
return configurations.getByName("classpath")
.plus(configurations.detachedConfiguration(handler.localGroovy()));
}
private static URL[] getTestClasspath() {
return ((URLClassLoader) ForkingJavaExec.class.getClassLoader()).getURLs();
}
}

View file

@ -72,6 +72,8 @@ trait ProjectTestTrait {
}
BuildResult create(String task, String gradleVersion = "6.8.3") {
System.setProperty("fabric.loom.test", "true")
GradleRunner.create()
.withProjectDir(testProjectDir)
.withArguments(task, "--stacktrace", "--warning-mode", warningMode(gradleVersion), "--gradle-user-home", gradleHomeDirectory(gradleVersion))