mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 13:37:45 -05:00
Fix build
This commit is contained in:
@@ -200,8 +200,7 @@ public class MappingsProvider extends DependencyProvider {
|
||||
processorManager.setupProcessors();
|
||||
|
||||
if (extension.isForge()) {
|
||||
patchedProvider = new MinecraftPatchedProvider(getProject());
|
||||
patchedProvider.provide(dependency, postPopulationScheduler);
|
||||
patchedProvider = new MinecraftPatchedProvider(this, getProject());
|
||||
}
|
||||
|
||||
if (processorManager.active() || (extension.isForge() && patchedProvider.usesProjectCache())) {
|
||||
@@ -211,6 +210,9 @@ public class MappingsProvider extends DependencyProvider {
|
||||
mappedProvider = new MinecraftMappedProvider(getProject());
|
||||
}
|
||||
|
||||
if (extension.isForge()) {
|
||||
patchedProvider.provide(dependency, postPopulationScheduler);
|
||||
}
|
||||
mappedProvider.initFiles(minecraftProvider, this);
|
||||
mappedProvider.provide(dependency, postPopulationScheduler);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class CleanLoomBinaries extends AbstractLoomTask {
|
||||
Optional.ofNullable(extension.getMinecraftMappedProvider().getSrgJar()).ifPresent(File::delete);
|
||||
if (extension.isForge()) {
|
||||
try {
|
||||
MinecraftPatchedProvider provider = new MinecraftPatchedProvider(getProject());
|
||||
MinecraftPatchedProvider provider = new MinecraftPatchedProvider(extension.getMappingsProvider(), getProject());
|
||||
provider.initFiles();
|
||||
provider.cleanCache();
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.fabricmc.loom.util.srg;
|
||||
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.providers.MappingsProvider;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.tasks.JavaExec;
|
||||
@@ -20,12 +21,14 @@ import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
public class SpecialSourceExecutor {
|
||||
public static Path produceSrgJar(Project project, File specialSourceJar, Path officialJar, Path srgPath) throws Exception {
|
||||
public static Path produceSrgJar(Project project, MappingsProvider provider, String side, File specialSourceJar, Path officialJar, Path srgPath)
|
||||
throws Exception {
|
||||
Set<String> filter = Files.readAllLines(srgPath, StandardCharsets.UTF_8).stream()
|
||||
.filter(s -> !s.startsWith("\t"))
|
||||
.map(s -> s.split(" ")[0] + ".class")
|
||||
.collect(Collectors.toSet());
|
||||
Path stripped = project.getExtensions().getByType(LoomGradleExtension.class).getProjectBuildCache().toPath().resolve(officialJar.getFileName().toString().substring(0, officialJar.getFileName().toString().length() - 4) + "-filtered.jar");
|
||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
Path stripped = extension.getProjectBuildCache().toPath().resolve(officialJar.getFileName().toString().substring(0, officialJar.getFileName().toString().length() - 4) + "-filtered.jar");
|
||||
Files.deleteIfExists(stripped);
|
||||
try (JarOutputStream output = new JarOutputStream(Files.newOutputStream(stripped))) {
|
||||
ZipUtil.iterate(officialJar.toFile(), (in, zipEntry) -> {
|
||||
@@ -36,7 +39,8 @@ public class SpecialSourceExecutor {
|
||||
}
|
||||
});
|
||||
}
|
||||
Path output = tmpFile();
|
||||
Path output = extension.getProjectBuildCache().toPath().resolve(officialJar.getFileName().toString().substring(0, officialJar.getFileName().toString().length() - 4) + "-srg-output.jar");
|
||||
Files.deleteIfExists(output);
|
||||
|
||||
String[] args = new String[]{
|
||||
"--in-jar",
|
||||
@@ -47,6 +51,7 @@ public class SpecialSourceExecutor {
|
||||
srgPath.toAbsolutePath().toString()
|
||||
};
|
||||
|
||||
project.getLogger().lifecycle(":remapping minecraft (SpecialSource, " + side + ", official -> srg)");
|
||||
JavaExec java = project.getTasks().create("PleaseIgnore_JavaExec_" + UUID.randomUUID().toString().replace("-", ""), JavaExec.class);
|
||||
java.setArgs(Arrays.asList(args));
|
||||
java.setClasspath(project.files(specialSourceJar));
|
||||
@@ -60,11 +65,14 @@ public class SpecialSourceExecutor {
|
||||
project.getTasks().remove(java);
|
||||
}
|
||||
|
||||
// TODO: Figure out why doing this produces a different result? Possible different class path?
|
||||
// SpecialSource.main(args);
|
||||
|
||||
Files.deleteIfExists(stripped);
|
||||
return output;
|
||||
|
||||
Path tmp = tmpFile();
|
||||
Files.deleteIfExists(tmp);
|
||||
Files.copy(output, tmp);
|
||||
|
||||
Files.deleteIfExists(output);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
private static Path tmpFile() throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user