Rewrite Minecraft Library handling. (#857)

This PR rewrites the Minecraft library processing with a more structured and testable set of "library processors". The old code is a mess of special cases and work arounds for various issues on various platforms.

Previously this was only really used on lesser used platforms/versions so wasnt a major issue if things broke, however current shipping Minecraft versions (1.19.4) use an LWJGL version that does not work well on Java versions new than 19. With this change LWJGL is upgraded when using Java 19 or later.

Upgraded libraries are also now only placed on the runtime classpath, this prevents you from using newer library features in your mod.
This commit is contained in:
modmuss50
2023-04-17 00:07:52 +01:00
committed by GitHub
parent 95a260d923
commit c16303b9b2
50 changed files with 2523 additions and 480 deletions

View File

@@ -71,7 +71,7 @@ import net.fabricmc.loom.decompilers.LineNumberRemapper;
import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.FileSystemUtil;
import net.fabricmc.loom.util.IOStringConsumer;
import net.fabricmc.loom.util.OperatingSystem;
import net.fabricmc.loom.util.Platform;
import net.fabricmc.loom.util.gradle.ThreadedProgressLoggerConsumer;
import net.fabricmc.loom.util.gradle.ThreadedSimpleProgressLogger;
import net.fabricmc.loom.util.gradle.WorkerDaemonClientsManagerHelper;
@@ -124,11 +124,13 @@ public abstract class GenerateSourcesTask extends AbstractLoomTask {
@TaskAction
public void run() throws IOException {
if (!OperatingSystem.is64Bit()) {
final Platform platform = Platform.CURRENT;
if (!platform.getArchitecture().is64Bit()) {
throw new UnsupportedOperationException("GenSources task requires a 64bit JVM to run due to the memory requirements.");
}
if (!OperatingSystem.isUnixDomainSocketsSupported()) {
if (!platform.supportsUnixDomainSockets()) {
getProject().getLogger().warn("Decompile worker logging disabled as Unix Domain Sockets is not supported on your operating system.");
doWork(null);
@@ -167,7 +169,7 @@ public abstract class GenerateSourcesTask extends AbstractLoomTask {
params.getIPCPath().set(ipcServer.getPath().toFile());
}
params.getClassPath().setFrom(getProject().getConfigurations().getByName(Constants.Configurations.MINECRAFT_DEPENDENCIES));
params.getClassPath().setFrom(getProject().getConfigurations().getByName(Constants.Configurations.MINECRAFT_COMPILE_LIBRARIES));
});
try {
@@ -223,7 +225,7 @@ public abstract class GenerateSourcesTask extends AbstractLoomTask {
public abstract static class DecompileAction implements WorkAction<DecompileParams> {
@Override
public void execute() {
if (!getParameters().getIPCPath().isPresent() || !OperatingSystem.isUnixDomainSocketsSupported()) {
if (!getParameters().getIPCPath().isPresent() || !Platform.CURRENT.supportsUnixDomainSockets()) {
// Does not support unix domain sockets, print to sout.
doDecompile(System.out::println);
return;