Decompiler API improvements:

* Fix decompiler tasks getting registered in afterEvaluate
* Allow decompilers to add file collections to the forked JVM classpath.
* General code cleanup.
This commit is contained in:
modmuss50
2021-12-29 00:10:58 +00:00
parent e4244dc895
commit 53b839b739
9 changed files with 106 additions and 73 deletions

View File

@@ -42,11 +42,13 @@ import java.util.stream.Collectors;
import javax.inject.Inject;
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.FileCollection;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.provider.MapProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputFile;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.TaskAction;
import org.gradle.workers.WorkAction;
import org.gradle.workers.WorkParameters;
@@ -87,6 +89,9 @@ public abstract class GenerateSourcesTask extends AbstractLoomTask {
@Input
public abstract MapProperty<String, String> getOptions();
@InputFiles
public abstract ConfigurableFileCollection getClasspath();
@Inject
public abstract WorkerExecutor getWorkerExecutor();
@@ -100,6 +105,12 @@ public abstract class GenerateSourcesTask extends AbstractLoomTask {
Objects.requireNonNull(getDecompilerConstructor(this.decompiler.getClass().getCanonicalName()),
"%s must have a no args constructor".formatted(this.decompiler.getClass().getCanonicalName()));
FileCollection decompilerClasspath = decompiler.getBootstrapClasspath(getProject());
if (decompilerClasspath != null) {
getClasspath().from(decompilerClasspath);
}
getOutputs().upToDateWhen((o) -> false);
getMaxMemory().convention(4096L).finalizeValueOnRead();
getOptions().finalizeValueOnRead();
@@ -177,6 +188,7 @@ public abstract class GenerateSourcesTask extends AbstractLoomTask {
spec.forkOptions(forkOptions -> {
forkOptions.setMaxHeapSize("%dm".formatted(getMaxMemory().get()));
forkOptions.systemProperty(WorkerDaemonClientsManagerHelper.MARKER_PROP, jvmMarkerValue);
forkOptions.bootstrapClasspath(getClasspath());
});
});
}