mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-03-28 04:07:01 -05:00
Fix merge conflicts, it compiles, but shouldn't work
Signed-off-by: shedaniel <daniel@shedaniel.me>
This commit is contained in:
1
.github/workflows/publish.yml
vendored
1
.github/workflows/publish.yml
vendored
@@ -8,7 +8,6 @@ on:
|
||||
- 'dev/0.8'
|
||||
- 'dev/0.9'
|
||||
- 'dev/0.10.0'
|
||||
- 'dev/0.11.0'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
@@ -153,7 +153,7 @@ public interface LoomGradleExtensionAPI {
|
||||
// ===================
|
||||
// Architectury Loom
|
||||
// ===================
|
||||
ListProperty<ArchitecturyLoomDecompiler> getArchGameDecompilers();
|
||||
DomainObjectCollection<ArchitecturyLoomDecompiler> getArchGameDecompilers();
|
||||
|
||||
default void addArchDecompiler(ArchitecturyLoomDecompiler decompiler) {
|
||||
getArchGameDecompilers().add(decompiler);
|
||||
|
||||
@@ -94,7 +94,7 @@ public class ModCompileRemapper {
|
||||
String name = extension.isForgeAndOfficial() ? "B" + checksum.get() : artifact.getModuleVersion().getId().getName();
|
||||
String version = extension.isForgeAndOfficial() ? "B" + checksum.get() : replaceIfNullOrEmpty(artifact.getModuleVersion().getId().getVersion(), () -> Checksum.truncatedSha256(artifact.getFile()));
|
||||
|
||||
if (!ModUtils.shouldRemapMod(artifact.getFile(), artifact.getId(), extension.isForge(), sourceConfig.getName())) {
|
||||
if (!ModUtils.shouldRemapMod(project.getLogger(), artifact.getFile(), artifact.getId(), extension.isForge(), sourceConfig.getName())) {
|
||||
addToRegularCompile(project, regularConfig, artifact);
|
||||
continue;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class ModCompileRemapper {
|
||||
|
||||
// Create a mod dependency for each file in the file collection
|
||||
for (File artifact : files) {
|
||||
if (!ModUtils.shouldRemapMod(artifact, artifact.getName(), extension.isForge(), sourceConfig.getName())) {
|
||||
if (!ModUtils.shouldRemapMod(project.getLogger(), artifact, artifact.getName(), extension.isForge(), sourceConfig.getName())) {
|
||||
dependencies.add(regularConfig.getName(), project.files(artifact));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@ public abstract class AnnotationProcessorInvoker<T extends Task> {
|
||||
}
|
||||
|
||||
public void configureMixin() {
|
||||
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||
ConfigurationContainer configs = project.getConfigurations();
|
||||
|
||||
if (!IdeaUtils.isIdeaSync()) {
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* This file is part of fabric-loom, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2021 FabricMC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.fabricmc.loom.build.nesting;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public enum EmptyNestedJarProvider implements NestedJarProvider {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public Collection<File> provide() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import org.gradle.api.NamedDomainObjectProvider;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
import org.gradle.api.plugins.JavaPlugin;
|
||||
import org.gradle.api.plugins.JavaPluginConvention;
|
||||
import org.gradle.api.plugins.JavaPluginExtension;
|
||||
import org.gradle.api.tasks.AbstractCopyTask;
|
||||
import org.gradle.api.tasks.SourceSet;
|
||||
@@ -54,7 +55,6 @@ import net.fabricmc.loom.configuration.providers.forge.SrgProvider;
|
||||
import net.fabricmc.loom.configuration.providers.mappings.MappingsProviderImpl;
|
||||
import net.fabricmc.loom.extension.MixinExtension;
|
||||
import net.fabricmc.loom.task.GenerateSourcesTask;
|
||||
import net.fabricmc.loom.task.GenVsCodeProjectTask;
|
||||
import net.fabricmc.loom.task.UnpickJarTask;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
|
||||
@@ -124,6 +124,7 @@ public final class CompileConfiguration {
|
||||
if (extension.supportsInclude()) {
|
||||
extension.createLazyConfiguration(Constants.Configurations.INCLUDE, configuration -> configuration.setTransitive(false)); // Dont get transitive deps
|
||||
}
|
||||
|
||||
extension.createLazyConfiguration(Constants.Configurations.MAPPING_CONSTANTS);
|
||||
extension.createLazyConfiguration(Constants.Configurations.NAMED_ELEMENTS, configuration -> {
|
||||
configuration.setCanBeConsumed(true);
|
||||
|
||||
@@ -91,7 +91,7 @@ public record AccessWidenerFile(
|
||||
content
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import dev.architectury.tinyremapper.TinyRemapper;
|
||||
import org.gradle.api.Project;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
@@ -57,7 +58,6 @@ import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.Pair;
|
||||
import net.fabricmc.loom.util.TinyRemapperHelper;
|
||||
import net.fabricmc.loom.util.ZipUtils;
|
||||
import net.fabricmc.tinyremapper.TinyRemapper;
|
||||
|
||||
public class InterfaceInjectionProcessor implements JarProcessor {
|
||||
// Filename used to store hash of injected interfaces in processed jar file
|
||||
|
||||
@@ -117,6 +117,7 @@ public class ModProcessor {
|
||||
|
||||
private void stripNestedJars(File file) {
|
||||
if (!ZipUtils.contains(file.toPath(), "fabric.mod.json")) return;
|
||||
|
||||
// Strip out all contained jar info as we dont want loader to try and load the jars contained in dev.
|
||||
try {
|
||||
ZipUtils.transformJson(JsonObject.class, file.toPath(), Map.of("fabric.mod.json", json -> {
|
||||
@@ -174,6 +175,7 @@ public class ModProcessor {
|
||||
if (extension.isForgeAndNotOfficial()) {
|
||||
remapper.readClassPathAsync(mappedProvider.getForgeSrgJar().toPath());
|
||||
}
|
||||
|
||||
remapper.readClassPathAsync(mcDeps);
|
||||
|
||||
final Map<ModDependencyInfo, InputTag> tagMap = new HashMap<>();
|
||||
|
||||
@@ -64,8 +64,7 @@ public class MinecraftProviderImpl extends DependencyProvider implements Minecra
|
||||
// The extracted server jar from the boostrap, only exists in >=21w39a
|
||||
public File minecraftExtractedServerJar;
|
||||
@Nullable
|
||||
private BundleMetadata serverBundleMetadata;
|
||||
private Boolean isNewerThan21w39a;
|
||||
public BundleMetadata serverBundleMetadata;
|
||||
private File minecraftMergedJar;
|
||||
private File versionManifestJson;
|
||||
private File experimentalVersionsJson;
|
||||
|
||||
@@ -59,10 +59,10 @@ import org.gradle.api.attributes.Attribute;
|
||||
import org.gradle.api.file.FileSystemLocation;
|
||||
import org.gradle.api.provider.Provider;
|
||||
|
||||
import net.fabricmc.loom.api.ForgeLocalMod;
|
||||
import net.fabricmc.loom.configuration.DependencyProvider;
|
||||
import net.fabricmc.loom.configuration.ide.RunConfigSettings;
|
||||
import net.fabricmc.loom.configuration.launch.LaunchProviderSettings;
|
||||
import net.fabricmc.loom.api.ForgeLocalMod;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.DependencyDownloader;
|
||||
import net.fabricmc.loom.util.FileSystemUtil;
|
||||
@@ -254,7 +254,7 @@ public class ForgeUserdevProvider extends DependencyProvider {
|
||||
} else if (key.equals("assets_root")) {
|
||||
string = new File(getDirectories().getUserCache(), "assets").getAbsolutePath();
|
||||
} else if (key.equals("natives")) {
|
||||
string = getMinecraftProvider().nativesDir().getAbsolutePath();
|
||||
string = getExtension().getFiles().getNativesDirectory(getProject()).getAbsolutePath();
|
||||
} else if (key.equals("source_roots")) {
|
||||
List<String> modClasses = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ import java.util.jar.Manifest;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -338,7 +339,7 @@ public class MinecraftPatchedProvider extends DependencyProvider {
|
||||
|
||||
private void createSrgJars(Logger logger) throws Exception {
|
||||
MinecraftProviderImpl minecraftProvider = getExtension().getMinecraftProvider();
|
||||
produceSrgJar(getExtension().isForgeAndOfficial(), minecraftProvider.minecraftClientJar.toPath(), minecraftProvider.getMinecraftServerJar().toPath());
|
||||
produceSrgJar(getExtension().isForgeAndOfficial(), minecraftProvider.minecraftClientJar.toPath(), MoreObjects.firstNonNull(minecraftProvider.minecraftExtractedServerJar, minecraftProvider.minecraftServerJar).toPath());
|
||||
}
|
||||
|
||||
private void produceSrgJar(boolean official, Path clientJar, Path serverJar) throws IOException {
|
||||
@@ -480,7 +481,7 @@ public class MinecraftPatchedProvider extends DependencyProvider {
|
||||
private void accessTransformForge(Logger logger) throws Exception {
|
||||
MinecraftProviderImpl minecraftProvider = getExtension().getMinecraftProvider();
|
||||
List<File> toDelete = new ArrayList<>();
|
||||
String atDependency = Constants.Dependencies.ACCESS_TRANSFORMERS + (minecraftProvider.isNewerThan21w39a() ? Constants.Dependencies.Versions.ACCESS_TRANSFORMERS_NEW : Constants.Dependencies.Versions.ACCESS_TRANSFORMERS);
|
||||
String atDependency = Constants.Dependencies.ACCESS_TRANSFORMERS + (minecraftProvider.serverBundleMetadata != null ? Constants.Dependencies.Versions.ACCESS_TRANSFORMERS_NEW : Constants.Dependencies.Versions.ACCESS_TRANSFORMERS);
|
||||
FileCollection classpath = DependencyDownloader.download(getProject(), atDependency);
|
||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
|
||||
@@ -653,7 +654,7 @@ public class MinecraftPatchedProvider extends DependencyProvider {
|
||||
// Copy resources
|
||||
MinecraftProviderImpl minecraftProvider = getExtension().getMinecraftProvider();
|
||||
copyNonClassFiles(minecraftProvider.minecraftClientJar, minecraftMergedPatchedSrgJar);
|
||||
copyNonClassFiles(minecraftProvider.getMinecraftServerJar(), minecraftMergedPatchedSrgJar);
|
||||
copyNonClassFiles(MoreObjects.firstNonNull(minecraftProvider.minecraftExtractedServerJar, minecraftProvider.minecraftServerJar), minecraftMergedPatchedSrgJar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,13 +30,9 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
@@ -45,13 +41,10 @@ import dev.architectury.tinyremapper.InputTag;
|
||||
import dev.architectury.tinyremapper.NonClassCopyMode;
|
||||
import dev.architectury.tinyremapper.OutputConsumerPath;
|
||||
import dev.architectury.tinyremapper.TinyRemapper;
|
||||
import dev.architectury.tinyremapper.api.TrClass;
|
||||
import org.apache.commons.lang3.mutable.Mutable;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
import org.gradle.api.Project;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.commons.Remapper;
|
||||
|
||||
import net.fabricmc.loom.api.mappings.layered.MappingsNamespace;
|
||||
import net.fabricmc.loom.configuration.DependencyProvider;
|
||||
@@ -274,7 +267,6 @@ public class MinecraftMappedProvider extends DependencyProvider {
|
||||
InputTag vanillaTag = remapper.createInputTag();
|
||||
InputTag forgeTag = remapper.createInputTag();
|
||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
final boolean fixSignatures = getExtension().getMappingsProvider().getSignatureFixes() != null;
|
||||
getProject().getLogger().lifecycle(":remapping minecraft (TinyRemapper, " + fromM + " -> " + toM + ")");
|
||||
|
||||
remapper.readInputs(vanillaTag, vanilla.input);
|
||||
@@ -287,53 +279,7 @@ public class MinecraftMappedProvider extends DependencyProvider {
|
||||
if (!MappingsNamespace.INTERMEDIARY.toString().equals(toM)) mappings.setValue(null);
|
||||
postApply.clear();
|
||||
|
||||
// Bit ugly but whatever, the whole issue is a bit ugly :)
|
||||
AtomicReference<Map<String, String>> remappedSignatures = new AtomicReference<>();
|
||||
|
||||
if (fixSignatures) {
|
||||
postApply.add(new TinyRemapper.ApplyVisitorProvider() {
|
||||
@Override
|
||||
public ClassVisitor insertApplyVisitor(TrClass cls, ClassVisitor next) {
|
||||
return new ClassVisitor(Constants.ASM_VERSION, next) {
|
||||
@Override
|
||||
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
|
||||
Map<String, String> signatureFixes = Objects.requireNonNull(remappedSignatures.get(), "Could not get remapped signatures");
|
||||
|
||||
if (signature == null) {
|
||||
signature = signatureFixes.getOrDefault(name, null);
|
||||
|
||||
if (signature != null) {
|
||||
getProject().getLogger().info("Replaced signature for {} with {}", name, signature);
|
||||
}
|
||||
}
|
||||
|
||||
super.visit(version, access, name, signature, superName, interfaces);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
if (MappingsNamespace.INTERMEDIARY.toString().equals(toM)) {
|
||||
// No need to remap, as these are already intermediary
|
||||
remappedSignatures.set(getExtension().getMappingsProvider().getSignatureFixes());
|
||||
} else {
|
||||
// Remap the sig fixes from intermediary to the target namespace
|
||||
final Map<String, String> remapped = new HashMap<>();
|
||||
final TinyRemapper sigTinyRemapper = TinyRemapperHelper.getTinyRemapper(getProject(), fromM, toM);
|
||||
final Remapper sigAsmRemapper = sigTinyRemapper.getRemapper();
|
||||
|
||||
// Remap the class names and the signatures using a new tiny remapper instance.
|
||||
for (Map.Entry<String, String> entry : getExtension().getMappingsProvider().getSignatureFixes().entrySet()) {
|
||||
remapped.put(
|
||||
sigAsmRemapper.map(entry.getKey()),
|
||||
sigAsmRemapper.mapSignature(entry.getValue(), false)
|
||||
);
|
||||
}
|
||||
|
||||
sigTinyRemapper.finish();
|
||||
remappedSignatures.set(remapped);
|
||||
}
|
||||
}
|
||||
postApply.add(new SignatureFixerApplyVisitor(SignatureFixerApplyVisitor.getRemappedSignatures(MappingsNamespace.INTERMEDIARY.toString().equals(toM), getExtension().getMappingsProvider(), getProject(), toM)));
|
||||
|
||||
OutputRemappingHandler.remap(remapper, vanilla.assets, output, null, vanillaTag);
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import dev.architectury.tinyremapper.TinyRemapper;
|
||||
import dev.architectury.tinyremapper.api.TrClass;
|
||||
import org.gradle.api.Project;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.commons.Remapper;
|
||||
@@ -37,8 +39,6 @@ import net.fabricmc.loom.api.mappings.layered.MappingsNamespace;
|
||||
import net.fabricmc.loom.configuration.providers.mappings.MappingsProviderImpl;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.TinyRemapperHelper;
|
||||
import net.fabricmc.tinyremapper.TinyRemapper;
|
||||
import net.fabricmc.tinyremapper.api.TrClass;
|
||||
|
||||
public record SignatureFixerApplyVisitor(Map<String, String> signatureFixes) implements TinyRemapper.ApplyVisitorProvider {
|
||||
@Override
|
||||
|
||||
@@ -89,7 +89,7 @@ public abstract class LoomGradleExtensionApiImpl implements LoomGradleExtensionA
|
||||
// ===================
|
||||
// Architectury Loom
|
||||
// ===================
|
||||
private final ListProperty<ArchitecturyLoomDecompiler> archDecompilers;
|
||||
private final DomainObjectCollection<ArchitecturyLoomDecompiler> archDecompilers;
|
||||
private Provider<ModPlatform> platform;
|
||||
private boolean silentMojangMappingsLicense = false;
|
||||
public Boolean generateSrgTiny = null;
|
||||
@@ -142,8 +142,7 @@ public abstract class LoomGradleExtensionApiImpl implements LoomGradleExtensionA
|
||||
})::get);
|
||||
this.launchConfigs = project.container(LaunchProviderSettings.class,
|
||||
baseName -> new LaunchProviderSettings(project, baseName));
|
||||
this.archDecompilers = project.getObjects().listProperty(ArchitecturyLoomDecompiler.class)
|
||||
.empty();
|
||||
this.archDecompilers = project.getObjects().domainObjectSet(ArchitecturyLoomDecompiler.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -300,7 +299,7 @@ public abstract class LoomGradleExtensionApiImpl implements LoomGradleExtensionA
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListProperty<ArchitecturyLoomDecompiler> getArchGameDecompilers() {
|
||||
public DomainObjectCollection<ArchitecturyLoomDecompiler> getArchGameDecompilers() {
|
||||
return archDecompilers;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.gradle.api.Project;
|
||||
import org.gradle.api.Task;
|
||||
import org.gradle.api.UnknownTaskException;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
import org.gradle.api.plugins.BasePluginConvention;
|
||||
import org.gradle.api.plugins.BasePluginExtension;
|
||||
import org.gradle.api.plugins.JavaPluginExtension;
|
||||
import org.gradle.api.provider.Property;
|
||||
@@ -72,6 +73,7 @@ public class MixinExtensionImpl extends MixinExtensionApiImpl implements MixinEx
|
||||
if (project.getRootProject() != project) {
|
||||
defaultRefmapName = project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName() + "-" + project.getPath().replaceFirst(":", "").replace(':', '_') + "-refmap.json";
|
||||
}
|
||||
|
||||
project.getLogger().info("Could not find refmap definition, will be using default name: " + defaultRefmapName);
|
||||
return defaultRefmapName;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.gradle.workers.WorkQueue;
|
||||
import org.gradle.workers.WorkerExecutor;
|
||||
|
||||
import net.fabricmc.loom.api.mappings.layered.MappingsNamespace;
|
||||
import net.fabricmc.loom.util.SourceRemapper;
|
||||
import net.fabricmc.loom.util.ZipReprocessorUtil;
|
||||
|
||||
public abstract class AbstractRemapJarTask extends Jar {
|
||||
@@ -64,7 +65,7 @@ public abstract class AbstractRemapJarTask extends Jar {
|
||||
@Inject
|
||||
public AbstractRemapJarTask() {
|
||||
getSourceNamespace().convention(MappingsNamespace.NAMED.toString()).finalizeValueOnRead();
|
||||
getTargetNamespace().convention(MappingsNamespace.INTERMEDIARY.toString()).finalizeValueOnRead();
|
||||
getTargetNamespace().convention(SourceRemapper.intermediary(getProject())).finalizeValueOnRead();
|
||||
}
|
||||
|
||||
public final <P extends AbstractRemapParams> void submitWork(Class<? extends AbstractRemapAction<P>> workAction, Action<P> action) {
|
||||
|
||||
@@ -33,7 +33,6 @@ import javax.inject.Inject;
|
||||
|
||||
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.TaskAction;
|
||||
|
||||
@@ -89,19 +89,6 @@ public final class LoomTasks {
|
||||
t.dependsOn("downloadAssets");
|
||||
t.setGroup(Constants.TaskGroup.IDE);
|
||||
});
|
||||
|
||||
tasks.register("genIntelliJRuns", AbstractLoomTask.class, t -> {
|
||||
t.setDescription("Generates IntelliJ IDEA launch configurations.");
|
||||
t.dependsOn("downloadAssets");
|
||||
t.setGroup("ide");
|
||||
t.doLast(task -> {
|
||||
try {
|
||||
SetupIntelijRunConfigs.generate(task.getProject(), true);
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private static void registerRunTasks(TaskContainer tasks, Project project) {
|
||||
@@ -148,19 +135,14 @@ public final class LoomTasks {
|
||||
});
|
||||
});
|
||||
|
||||
for (ArchitecturyLoomDecompiler decompiler : extension.getArchGameDecompilers().get()) {
|
||||
String taskName = "genSourcesWith" + decompiler.name();
|
||||
// Decompiler will be passed to the constructor of ArchitecturyGenerateSourcesTask
|
||||
tasks.register(taskName, ArchitecturyGenerateSourcesTask.class, decompiler).configure(task -> {
|
||||
task.setDescription("Decompile minecraft using %s.".formatted(decompiler.name()));
|
||||
task.setGroup(Constants.TaskGroup.FABRIC);
|
||||
task.getInputJar().set(inputJar);
|
||||
|
||||
if (mappingsProvider.hasUnpickDefinitions()) {
|
||||
task.dependsOn(tasks.getByName("unpickJar"));
|
||||
}
|
||||
});
|
||||
}
|
||||
LoomGradleExtension.get(project).getArchGameDecompilers().configureEach(decompiler -> {
|
||||
String taskName = "genSourcesWith" + decompiler.name();
|
||||
// Decompiler will be passed to the constructor of ArchitecturyGenerateSourcesTask
|
||||
tasks.register(taskName, ArchitecturyGenerateSourcesTask.class, decompiler).configure(task -> {
|
||||
task.setDescription("Decompile minecraft using %s.".formatted(decompiler.name()));
|
||||
task.setGroup(Constants.TaskGroup.FABRIC);
|
||||
});
|
||||
});
|
||||
|
||||
tasks.register("genSources", task -> {
|
||||
task.setDescription("Decompile minecraft using the default decompiler.");
|
||||
|
||||
@@ -24,16 +24,24 @@
|
||||
|
||||
package net.fabricmc.loom.task;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.FileAlreadyExistsException;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -41,6 +49,13 @@ import javax.inject.Inject;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.gson.JsonObject;
|
||||
import dev.architectury.tinyremapper.InputTag;
|
||||
import dev.architectury.tinyremapper.OutputConsumerPath;
|
||||
import dev.architectury.tinyremapper.TinyRemapper;
|
||||
import dev.architectury.tinyremapper.TinyUtils;
|
||||
import org.cadixdev.at.AccessTransformSet;
|
||||
import org.cadixdev.at.io.AccessTransformFormats;
|
||||
import org.cadixdev.lorenz.MappingSet;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
import org.gradle.api.file.ConfigurableFileCollection;
|
||||
import org.gradle.api.file.FileCollection;
|
||||
@@ -48,6 +63,7 @@ import org.gradle.api.plugins.JavaPlugin;
|
||||
import org.gradle.api.provider.ListProperty;
|
||||
import org.gradle.api.provider.Property;
|
||||
import org.gradle.api.provider.Provider;
|
||||
import org.gradle.api.provider.SetProperty;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.InputFiles;
|
||||
import org.gradle.api.tasks.SourceSet;
|
||||
@@ -69,11 +85,11 @@ import net.fabricmc.loom.extension.MixinExtension;
|
||||
import net.fabricmc.loom.task.service.JarManifestService;
|
||||
import net.fabricmc.loom.task.service.MappingsService;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.FileSystemUtil;
|
||||
import net.fabricmc.loom.util.LfWriter;
|
||||
import net.fabricmc.loom.util.ZipUtils;
|
||||
import net.fabricmc.tinyremapper.InputTag;
|
||||
import net.fabricmc.tinyremapper.OutputConsumerPath;
|
||||
import net.fabricmc.tinyremapper.TinyRemapper;
|
||||
import net.fabricmc.tinyremapper.TinyUtils;
|
||||
import net.fabricmc.loom.util.aw2at.Aw2At;
|
||||
import net.fabricmc.lorenztiny.TinyMappingsReader;
|
||||
|
||||
public abstract class RemapJarTask extends AbstractRemapJarTask {
|
||||
private static final String MANIFEST_PATH = "META-INF/MANIFEST.MF";
|
||||
@@ -84,6 +100,17 @@ public abstract class RemapJarTask extends AbstractRemapJarTask {
|
||||
@Input
|
||||
public abstract Property<Boolean> getAddNestedDependencies();
|
||||
|
||||
/**
|
||||
* Gets the jar paths to the access wideners that will be converted to ATs for Forge runtime.
|
||||
* If you specify multiple files, they will be merged into one.
|
||||
*
|
||||
* <p>The specified files will be converted and removed from the final jar.
|
||||
*
|
||||
* @return the property containing access widener paths in the final jar
|
||||
*/
|
||||
@Input
|
||||
public abstract SetProperty<String> getAtAccessWideners();
|
||||
|
||||
@Inject
|
||||
public RemapJarTask() {
|
||||
super();
|
||||
@@ -100,7 +127,7 @@ public abstract class RemapJarTask extends AbstractRemapJarTask {
|
||||
final LoomGradleExtension extension = LoomGradleExtension.get(getProject());
|
||||
|
||||
submitWork(RemapAction.class, params -> {
|
||||
if (getAddNestedDependencies().get()) {
|
||||
if (extension.supportsInclude() && getAddNestedDependencies().get()) {
|
||||
params.getNestedJars().from(getNestedJars());
|
||||
}
|
||||
|
||||
@@ -114,6 +141,14 @@ public abstract class RemapJarTask extends AbstractRemapJarTask {
|
||||
if (legacyMixin) {
|
||||
params.getMixinMappings().from(extension.getAllMixinMappings());
|
||||
setupLegacyMixinRefmapRemapping(params);
|
||||
} else if (extension.isForge()) {
|
||||
throw new RuntimeException("Forge must have useLegacyMixinAp enabled");
|
||||
}
|
||||
|
||||
params.getForge().set(extension.isForge());
|
||||
|
||||
if (extension.isForge()) {
|
||||
params.getAtAccessWideners().set(getAtAccessWideners());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -175,8 +210,13 @@ public abstract class RemapJarTask extends AbstractRemapJarTask {
|
||||
ConfigurableFileCollection getNestedJars();
|
||||
ConfigurableFileCollection getRemapClasspath();
|
||||
ConfigurableFileCollection getMixinMappings();
|
||||
|
||||
ListProperty<Provider<MappingsService>> getMappings();
|
||||
|
||||
Property<Boolean> getForge();
|
||||
|
||||
SetProperty<String> getAtAccessWideners();
|
||||
|
||||
Property<Boolean> getUseMixinExtension();
|
||||
|
||||
record RefmapData(List<String> mixinConfigs, String refmapName) implements Serializable { }
|
||||
@@ -201,7 +241,11 @@ public abstract class RemapJarTask extends AbstractRemapJarTask {
|
||||
remapAccessWidener();
|
||||
addRefmaps();
|
||||
addNestedJars();
|
||||
modifyJarManifest();
|
||||
|
||||
if (!getParameters().getForge().get()) {
|
||||
modifyJarManifest();
|
||||
}
|
||||
|
||||
rewriteJar();
|
||||
|
||||
tinyRemapper.finish();
|
||||
@@ -243,6 +287,62 @@ public abstract class RemapJarTask extends AbstractRemapJarTask {
|
||||
ZipUtils.replace(outputFile, accessWidenerFile.path(), remapped);
|
||||
}
|
||||
|
||||
private void convertAwToAt() throws IOException {
|
||||
if (!this.getParameters().getAtAccessWideners().isPresent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Set<String> atAccessWideners = this.getParameters().getAtAccessWideners().get();
|
||||
|
||||
if (atAccessWideners.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
AccessTransformSet at = AccessTransformSet.create();
|
||||
File jar = inputFile.toFile();
|
||||
|
||||
try (FileSystemUtil.Delegate fileSystem = FileSystemUtil.getJarFileSystem(jar, false)) {
|
||||
FileSystem fs = fileSystem.get();
|
||||
Path atPath = fs.getPath(Constants.Forge.ACCESS_TRANSFORMER_PATH);
|
||||
|
||||
if (Files.exists(atPath)) {
|
||||
throw new FileAlreadyExistsException("Jar " + jar + " already contains an access transformer - cannot convert AWs!");
|
||||
}
|
||||
|
||||
for (String aw : atAccessWideners) {
|
||||
Path awPath = fs.getPath(aw);
|
||||
|
||||
if (Files.notExists(awPath)) {
|
||||
throw new NoSuchFileException("Could not find AW '" + aw + "' to convert into AT!");
|
||||
}
|
||||
|
||||
try (BufferedReader reader = Files.newBufferedReader(awPath, StandardCharsets.UTF_8)) {
|
||||
at.merge(Aw2At.toAccessTransformSet(reader));
|
||||
}
|
||||
|
||||
Files.delete(awPath);
|
||||
}
|
||||
|
||||
List<Provider<MappingsService>> providers = getParameters().getMappings().get();
|
||||
|
||||
// This is a bit of a hack, but we are going to get the first one, it should be the default one
|
||||
if (providers.isEmpty()) {
|
||||
throw new IllegalStateException("No mappings provider found for AW to AT conversion!");
|
||||
}
|
||||
|
||||
MappingsService service = providers.get(0).get();
|
||||
|
||||
try (TinyMappingsReader reader = new TinyMappingsReader(service.getMemoryMappingTree(), service.getFromNamespace(), service.getToNamespace())) {
|
||||
MappingSet mappingSet = reader.read();
|
||||
at = at.remap(mappingSet);
|
||||
}
|
||||
|
||||
try (Writer writer = new LfWriter(Files.newBufferedWriter(atPath))) {
|
||||
AccessTransformFormats.FML.write(writer, at);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] remapAccessWidener(byte[] input, Remapper asmRemapper, String targetNamespace) {
|
||||
int version = AccessWidenerReader.readVersion(input);
|
||||
|
||||
@@ -313,7 +413,7 @@ public abstract class RemapJarTask extends AbstractRemapJarTask {
|
||||
}
|
||||
|
||||
if (getParameters().getUseMixinExtension().get()) {
|
||||
builder.extension(new net.fabricmc.tinyremapper.extension.mixin.MixinExtension());
|
||||
builder.extension(new dev.architectury.tinyremapper.extension.mixin.MixinExtension());
|
||||
}
|
||||
|
||||
TinyRemapper remapper = builder.build();
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.Optional;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
import dev.architectury.tinyremapper.TinyRemapper;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.artifacts.Dependency;
|
||||
import org.gradle.api.provider.Property;
|
||||
@@ -40,7 +41,6 @@ import org.gradle.util.GradleVersion;
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.LoomGradlePlugin;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.tinyremapper.TinyRemapper;
|
||||
|
||||
public abstract class JarManifestService implements BuildService<JarManifestService.Params> {
|
||||
interface Params extends BuildServiceParameters {
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
|
||||
import dev.architectury.tinyremapper.IMappingProvider;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.file.RegularFileProperty;
|
||||
import org.gradle.api.provider.Property;
|
||||
@@ -40,7 +41,6 @@ import net.fabricmc.loom.configuration.providers.mappings.MappingsProviderImpl;
|
||||
import net.fabricmc.loom.util.TinyRemapperHelper;
|
||||
import net.fabricmc.mappingio.MappingReader;
|
||||
import net.fabricmc.mappingio.tree.MemoryMappingTree;
|
||||
import net.fabricmc.tinyremapper.IMappingProvider;
|
||||
|
||||
public abstract class MappingsService implements BuildService<MappingsService.Params>, AutoCloseable {
|
||||
interface Params extends BuildServiceParameters {
|
||||
@@ -66,7 +66,7 @@ public abstract class MappingsService implements BuildService<MappingsService.Pa
|
||||
public static Provider<MappingsService> createDefault(Project project, String from, String to) {
|
||||
final MappingsProviderImpl mappingsProvider = LoomGradleExtension.get(project).getMappingsProvider();
|
||||
final String name = mappingsProvider.getBuildServiceName("mappingsProvider", from, to);
|
||||
return MappingsService.create(project, name, mappingsProvider.tinyMappings.toFile(), from, to, false);
|
||||
return MappingsService.create(project, name, (from.equals("srg") || to.equals("srg")) && LoomGradleExtension.get(project).shouldGenerateSrgTiny() ? mappingsProvider.tinyMappingsWithSrg.toFile() : mappingsProvider.tinyMappings.toFile(), from, to, false);
|
||||
}
|
||||
|
||||
private IMappingProvider mappingProvider = null;
|
||||
|
||||
@@ -26,6 +26,8 @@ package net.fabricmc.loom.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.gradle.api.logging.Logger;
|
||||
|
||||
public final class ModUtils {
|
||||
private ModUtils() {
|
||||
}
|
||||
@@ -33,4 +35,17 @@ public final class ModUtils {
|
||||
public static boolean isMod(File input) {
|
||||
return ZipUtils.contains(input.toPath(), "fabric.mod.json");
|
||||
}
|
||||
|
||||
public static boolean shouldRemapMod(Logger logger, File input, Object id, boolean forge, String config) {
|
||||
if (ZipUtils.contains(input.toPath(), "architectury.common.marker")) return true;
|
||||
if (forge && ZipUtils.contains(input.toPath(), "META-INF/mods.toml")) return true;
|
||||
if (!forge && isMod(input)) return true;
|
||||
|
||||
if (forge) {
|
||||
logger.lifecycle(":could not find forge mod in " + config + " but forcing: {}", id);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import net.fabricmc.loom.configuration.providers.mappings.intermediary.Intermedi
|
||||
import net.fabricmc.loom.configuration.providers.mappings.mojmap.MojangMappingsSpec
|
||||
import net.fabricmc.loom.configuration.providers.mappings.parchment.ParchmentMappingsSpec
|
||||
import net.fabricmc.loom.util.ClosureAction
|
||||
import spock.lang.Specification
|
||||
|
||||
class LayeredMappingSpecBuilderTest extends LayeredMappingsSpecification {
|
||||
def "simple mojmap" () {
|
||||
|
||||
Reference in New Issue
Block a user