diff --git a/src/main/java/net/fabricmc/loom/configuration/providers/forge/MinecraftPatchedProvider.java b/src/main/java/net/fabricmc/loom/configuration/providers/forge/MinecraftPatchedProvider.java index 32f10809..03895ecb 100644 --- a/src/main/java/net/fabricmc/loom/configuration/providers/forge/MinecraftPatchedProvider.java +++ b/src/main/java/net/fabricmc/loom/configuration/providers/forge/MinecraftPatchedProvider.java @@ -34,7 +34,6 @@ import java.io.OutputStream; import java.io.PrintStream; import java.io.UncheckedIOException; import java.net.URI; -import java.net.URL; import java.nio.charset.StandardCharsets; import java.nio.file.FileSystem; import java.nio.file.FileSystems; @@ -66,6 +65,7 @@ import net.minecraftforge.binarypatcher.ConsoleTool; import org.apache.commons.io.IOUtils; import org.apache.commons.io.output.NullOutputStream; import org.gradle.api.Project; +import org.gradle.api.file.FileCollection; import org.gradle.api.logging.LogLevel; import org.gradle.api.logging.Logger; import org.gradle.api.plugins.JavaPluginConvention; @@ -83,7 +83,6 @@ import net.fabricmc.loom.configuration.providers.minecraft.MinecraftMappedProvid import net.fabricmc.loom.util.Checksum; import net.fabricmc.loom.util.Constants; import net.fabricmc.loom.util.DependencyDownloader; -import net.fabricmc.loom.util.DownloadUtil; import net.fabricmc.loom.util.FileSystemUtil; import net.fabricmc.loom.util.JarUtil; import net.fabricmc.loom.util.ThreadingUtils; @@ -294,13 +293,14 @@ public class MinecraftPatchedProvider extends DependencyProvider { throw new IllegalStateException("Failed to find mappings '" + mappingsPath[0] + "' in " + mcpProvider.getMcp().getAbsolutePath() + "!"); } - File specialSourceJar = new File(getExtension().getUserCache(), "SpecialSource-1.8.3-shaded.jar"); - DownloadUtil.downloadIfChanged(new URL("https://repo1.maven.org/maven2/net/md-5/SpecialSource/1.8.3/SpecialSource-1.8.3-shaded.jar"), specialSourceJar, getProject().getLogger(), true); + String atDependency = Constants.Dependencies.SPECIAL_SOURCE + Constants.Dependencies.Versions.SPECIAL_SOURCE + ":shaded"; + // Do getFiles() to resolve it before multithreading it + FileCollection classpath = getProject().files(DependencyDownloader.download(getProject(), atDependency).getFiles()); ThreadingUtils.run(() -> { - Files.copy(SpecialSourceExecutor.produceSrgJar(getProject(), "client", specialSourceJar, minecraftProvider.minecraftClientJar.toPath(), tmpSrg[0]), minecraftClientSrgJar.toPath()); + Files.copy(SpecialSourceExecutor.produceSrgJar(getProject(), "client", classpath, minecraftProvider.minecraftClientJar.toPath(), tmpSrg[0]), minecraftClientSrgJar.toPath()); }, () -> { - Files.copy(SpecialSourceExecutor.produceSrgJar(getProject(), "server", specialSourceJar, minecraftProvider.minecraftServerJar.toPath(), tmpSrg[0]), minecraftServerSrgJar.toPath()); + Files.copy(SpecialSourceExecutor.produceSrgJar(getProject(), "server", classpath, minecraftProvider.minecraftServerJar.toPath(), tmpSrg[0]), minecraftServerSrgJar.toPath()); }); } diff --git a/src/main/java/net/fabricmc/loom/util/Constants.java b/src/main/java/net/fabricmc/loom/util/Constants.java index 5947f116..2ee721ed 100644 --- a/src/main/java/net/fabricmc/loom/util/Constants.java +++ b/src/main/java/net/fabricmc/loom/util/Constants.java @@ -93,6 +93,7 @@ public class Constants { public static final String JAVAX_ANNOTATIONS = "com.google.code.findbugs:jsr305:"; // I hate that I have to add these. public static final String FORGE_RUNTIME = "dev.architectury:architectury-loom-forge-runtime:"; public static final String ACCESS_TRANSFORMERS = "net.minecraftforge:accesstransformers:"; + public static final String SPECIAL_SOURCE = "net.md-5:SpecialSource:"; private Dependencies() { } @@ -108,6 +109,7 @@ public class Constants { public static final String JAVAX_ANNOTATIONS = "3.0.2"; public static final String FORGE_RUNTIME = "$LOOM_VERSION"; // replaced with current version at build time public static final String ACCESS_TRANSFORMERS = "2.2.0"; + public static final String SPECIAL_SOURCE = "1.8.3"; private Versions() { } diff --git a/src/main/java/net/fabricmc/loom/util/srg/SpecialSourceExecutor.java b/src/main/java/net/fabricmc/loom/util/srg/SpecialSourceExecutor.java index 11fae1a0..bfdf9332 100644 --- a/src/main/java/net/fabricmc/loom/util/srg/SpecialSourceExecutor.java +++ b/src/main/java/net/fabricmc/loom/util/srg/SpecialSourceExecutor.java @@ -24,7 +24,6 @@ package net.fabricmc.loom.util.srg; -import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -37,12 +36,13 @@ import java.util.zip.ZipEntry; import org.apache.commons.io.IOUtils; import org.gradle.api.Project; +import org.gradle.api.file.FileCollection; import org.zeroturnaround.zip.ZipUtil; import net.fabricmc.loom.LoomGradleExtension; public class SpecialSourceExecutor { - public static Path produceSrgJar(Project project, String side, File specialSourceJar, Path officialJar, Path srgPath) + public static Path produceSrgJar(Project project, String side, FileCollection specialSourceCp, Path officialJar, Path srgPath) throws Exception { Set filter = Files.readAllLines(srgPath, StandardCharsets.UTF_8).stream() .filter(s -> !s.startsWith("\t")) @@ -80,7 +80,7 @@ public class SpecialSourceExecutor { project.javaexec(spec -> { spec.setArgs(Arrays.asList(args)); - spec.setClasspath(project.files(specialSourceJar)); + spec.setClasspath(specialSourceCp); spec.workingDir(workingDir.toFile()); spec.setMain("net.md_5.specialsource.SpecialSource"); spec.setStandardOutput(System.out);