diff --git a/src/main/java/net/fabricmc/loom/LoomGradleExtension.java b/src/main/java/net/fabricmc/loom/LoomGradleExtension.java index f458478..7c086f7 100644 --- a/src/main/java/net/fabricmc/loom/LoomGradleExtension.java +++ b/src/main/java/net/fabricmc/loom/LoomGradleExtension.java @@ -28,8 +28,11 @@ import java.io.File; import java.nio.file.Path; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.function.BiPredicate; import java.util.function.Function; import java.util.function.Supplier; @@ -78,6 +81,7 @@ public class LoomGradleExtension { private JsonObject installerJson; private MappingSet[] srcMappingCache = new MappingSet[2]; private Mercury[] srcMercuryCache = new Mercury[2]; + private Set mixinMappings = Collections.synchronizedSet(new HashSet<>()); /** * Loom will generate a new genSources task (with a new name, based off of {@link LoomDecompiler#name()}) @@ -400,7 +404,15 @@ public class LoomGradleExtension { return shareCaches; } - public File getMixinMappings() { - return new File(getProjectBuildCache(), "mixin-map-" + getMinecraftProvider().getMinecraftVersion() + "-" + getMappingsProvider().mappingsVersion + ".tiny"); + // Creates a new file each time its called, this is then held onto later when remapping the output jar + // Required as now when using parallel builds the old single file could be written by another sourceset compile task + public synchronized File getNextMixinMappings() { + File mixinMapping = new File(getProjectBuildCache(), "mixin-map-" + getMinecraftProvider().getMinecraftVersion() + "-" + getMappingsProvider().mappingsVersion + "." + mixinMappings.size() + ".tiny"); + mixinMappings.add(mixinMapping); + return mixinMapping; + } + + public Set getAllMixinMappings() { + return Collections.unmodifiableSet(mixinMappings); } } diff --git a/src/main/java/net/fabricmc/loom/task/RemapJarTask.java b/src/main/java/net/fabricmc/loom/task/RemapJarTask.java index 3129563..dca964c 100644 --- a/src/main/java/net/fabricmc/loom/task/RemapJarTask.java +++ b/src/main/java/net/fabricmc/loom/task/RemapJarTask.java @@ -99,15 +99,14 @@ public class RemapJarTask extends Jar { ); Path[] classpath = classpathFiles.stream().map(File::toPath).filter((p) -> !input.equals(p) && Files.exists(p)).toArray(Path[]::new); - File mixinMapFile = extension.getMixinMappings(); - Path mixinMapPath = mixinMapFile.toPath(); - TinyRemapper.Builder remapperBuilder = TinyRemapper.newRemapper(); remapperBuilder = remapperBuilder.withMappings(TinyRemapperMappingsHelper.create(mappingsProvider.getMappings(), fromM, toM, false)); - if (mixinMapFile.exists()) { - remapperBuilder = remapperBuilder.withMappings(TinyUtils.createTinyMappingProvider(mixinMapPath, fromM, toM)); + for (File mixinMapFile : extension.getAllMixinMappings()) { + if (mixinMapFile.exists()) { + remapperBuilder = remapperBuilder.withMappings(TinyUtils.createTinyMappingProvider(mixinMapFile.toPath(), fromM, toM)); + } } project.getLogger().lifecycle(":remapping " + input.getFileName()); @@ -194,11 +193,10 @@ public class RemapJarTask extends Jar { jarRemapper.addMappings(TinyRemapperMappingsHelper.create(mappingsProvider.getMappings(), fromM, toM, false)); } - File mixinMapFile = extension.getMixinMappings(); - Path mixinMapPath = mixinMapFile.toPath(); - - if (mixinMapFile.exists()) { - jarRemapper.addMappings(TinyUtils.createTinyMappingProvider(mixinMapPath, fromM, toM)); + for (File mixinMapFile : extension.getAllMixinMappings()) { + if (mixinMapFile.exists()) { + jarRemapper.addMappings(TinyUtils.createTinyMappingProvider(mixinMapFile.toPath(), fromM, toM)); + } } jarRemapper.scheduleRemap(input, output) diff --git a/src/main/java/net/fabricmc/loom/util/mixin/AnnotationProcessorInvoker.java b/src/main/java/net/fabricmc/loom/util/mixin/AnnotationProcessorInvoker.java index 09eedc6..13b237c 100644 --- a/src/main/java/net/fabricmc/loom/util/mixin/AnnotationProcessorInvoker.java +++ b/src/main/java/net/fabricmc/loom/util/mixin/AnnotationProcessorInvoker.java @@ -73,7 +73,7 @@ public abstract class AnnotationProcessorInvoker { LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class); Map args = new HashMap() {{ put("inMapFileNamedIntermediary", extension.getMappingsProvider().tinyMappings.getCanonicalPath()); - put("outMapFileNamedIntermediary", extension.getMixinMappings().getCanonicalPath()); + put("outMapFileNamedIntermediary", extension.getNextMixinMappings().getCanonicalPath()); put("outRefMapFile", getRefmapDestination(task, extension)); put("defaultObfuscationEnv", "named:intermediary"); }};