mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 05:27:43 -05:00
Clean up manifest handling by not copying the vanilla ones
This commit is contained in:
@@ -32,11 +32,9 @@ import org.gradle.api.Project;
|
||||
|
||||
import net.fabricmc.loom.configuration.DependencyProvider;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.JarUtil;
|
||||
|
||||
public class ForgeUniversalProvider extends DependencyProvider {
|
||||
private File forge;
|
||||
private File forgeManifest;
|
||||
|
||||
public ForgeUniversalProvider(Project project) {
|
||||
super(project);
|
||||
@@ -45,26 +43,17 @@ public class ForgeUniversalProvider extends DependencyProvider {
|
||||
@Override
|
||||
public void provide(DependencyInfo dependency, Consumer<Runnable> postPopulationScheduler) throws Exception {
|
||||
forge = new File(getExtension().getProjectPersistentCache(), "forge-" + dependency.getDependency().getVersion() + "-universal.jar");
|
||||
forgeManifest = new File(getExtension().getProjectPersistentCache(), "forge-" + dependency.getDependency().getVersion() + "-manifest.mf");
|
||||
|
||||
if (!forge.exists() || isRefreshDeps()) {
|
||||
File dep = dependency.resolveFile().orElseThrow(() -> new RuntimeException("Could not resolve Forge"));
|
||||
FileUtils.copyFile(dep, forge);
|
||||
}
|
||||
|
||||
if (!forgeManifest.exists() || isRefreshDeps()) {
|
||||
JarUtil.extractFile(forge, "META-INF/MANIFEST.MF", forgeManifest);
|
||||
}
|
||||
}
|
||||
|
||||
public File getForge() {
|
||||
return forge;
|
||||
}
|
||||
|
||||
public File getForgeManifest() {
|
||||
return forgeManifest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetConfig() {
|
||||
return Constants.Configurations.FORGE_UNIVERSAL;
|
||||
|
||||
@@ -95,7 +95,7 @@ import net.fabricmc.mapping.tree.TinyTree;
|
||||
|
||||
public class MinecraftPatchedProvider extends DependencyProvider {
|
||||
private static final String LOOM_PATCH_VERSION_KEY = "Loom-Patch-Version";
|
||||
private static final String CURRENT_LOOM_PATCH_VERSION = "2";
|
||||
private static final String CURRENT_LOOM_PATCH_VERSION = "3";
|
||||
private static final String NAME_MAPPING_SERVICE_PATH = "/inject/META-INF/services/cpw.mods.modlauncher.api.INameMappingService";
|
||||
|
||||
// Step 1: Remap Minecraft to SRG (global)
|
||||
@@ -198,7 +198,8 @@ public class MinecraftPatchedProvider extends DependencyProvider {
|
||||
minecraftClientSrgJar,
|
||||
minecraftServerSrgJar,
|
||||
minecraftClientPatchedSrgJar,
|
||||
minecraftServerPatchedSrgJar
|
||||
minecraftServerPatchedSrgJar,
|
||||
minecraftMergedPatchedSrgJar,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -555,7 +556,12 @@ public class MinecraftPatchedProvider extends DependencyProvider {
|
||||
}
|
||||
|
||||
private void copyNonClassFiles(File source, File target) throws IOException {
|
||||
walkFileSystems(source, target, it -> !it.toString().endsWith(".class"), this::copyReplacing);
|
||||
Predicate<Path> filter = file -> {
|
||||
String s = file.toString();
|
||||
return !s.endsWith(".class") && !s.equalsIgnoreCase("/META-INF/MANIFEST.MF");
|
||||
};
|
||||
|
||||
walkFileSystems(source, target, filter, this::copyReplacing);
|
||||
}
|
||||
|
||||
private void copyReplacing(FileSystem sourceFs, FileSystem targetFs, Path sourcePath, Path targetPath) throws IOException {
|
||||
|
||||
@@ -25,13 +25,7 @@
|
||||
package net.fabricmc.loom.configuration.providers.minecraft;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URI;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
@@ -41,8 +35,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
@@ -214,33 +206,6 @@ public class MinecraftMappedProvider extends DependencyProvider {
|
||||
if (getExtension().isForge() && !"srg".equals(toM)) {
|
||||
getProject().getLogger().info(":running forge finalising tasks");
|
||||
|
||||
// TODO: Relocate this to its own class
|
||||
try (FileSystem fs = FileSystems.newFileSystem(URI.create("jar:" + output.toUri()), ImmutableMap.of("create", false))) {
|
||||
Path manifestPath = fs.getPath("META-INF", "MANIFEST.MF");
|
||||
Manifest minecraftManifest;
|
||||
Manifest forgeManifest;
|
||||
|
||||
try (InputStream in = Files.newInputStream(manifestPath)) {
|
||||
minecraftManifest = new Manifest(in);
|
||||
}
|
||||
|
||||
try (InputStream in = new FileInputStream(getExtension().getForgeUniversalProvider().getForgeManifest())) {
|
||||
forgeManifest = new Manifest(in);
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Attributes> forgeEntry : forgeManifest.getEntries().entrySet()) {
|
||||
if (forgeEntry.getKey().endsWith("/")) {
|
||||
minecraftManifest.getEntries().put(forgeEntry.getKey(), forgeEntry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
Files.delete(manifestPath);
|
||||
|
||||
try (OutputStream out = Files.newOutputStream(manifestPath)) {
|
||||
minecraftManifest.write(out);
|
||||
}
|
||||
}
|
||||
|
||||
TinyTree yarnWithSrg = getExtension().getMappingsProvider().getMappingsWithSrg();
|
||||
AtRemapper.remap(getProject().getLogger(), output, yarnWithSrg);
|
||||
CoreModClassRemapper.remapJar(output, yarnWithSrg, getProject().getLogger());
|
||||
|
||||
Reference in New Issue
Block a user