Fix race condition with mixin's output mappings across source sets
parent
20be96e733
commit
80aaf63832
|
@ -28,8 +28,11 @@ import java.io.File;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.function.BiPredicate;
|
import java.util.function.BiPredicate;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
@ -78,6 +81,7 @@ public class LoomGradleExtension {
|
||||||
private JsonObject installerJson;
|
private JsonObject installerJson;
|
||||||
private MappingSet[] srcMappingCache = new MappingSet[2];
|
private MappingSet[] srcMappingCache = new MappingSet[2];
|
||||||
private Mercury[] srcMercuryCache = new Mercury[2];
|
private Mercury[] srcMercuryCache = new Mercury[2];
|
||||||
|
private Set<File> mixinMappings = Collections.synchronizedSet(new HashSet<>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loom will generate a new genSources task (with a new name, based off of {@link LoomDecompiler#name()})
|
* 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;
|
return shareCaches;
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getMixinMappings() {
|
// Creates a new file each time its called, this is then held onto later when remapping the output jar
|
||||||
return new File(getProjectBuildCache(), "mixin-map-" + getMinecraftProvider().getMinecraftVersion() + "-" + getMappingsProvider().mappingsVersion + ".tiny");
|
// 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<File> getAllMixinMappings() {
|
||||||
|
return Collections.unmodifiableSet(mixinMappings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
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();
|
TinyRemapper.Builder remapperBuilder = TinyRemapper.newRemapper();
|
||||||
|
|
||||||
remapperBuilder = remapperBuilder.withMappings(TinyRemapperMappingsHelper.create(mappingsProvider.getMappings(), fromM, toM, false));
|
remapperBuilder = remapperBuilder.withMappings(TinyRemapperMappingsHelper.create(mappingsProvider.getMappings(), fromM, toM, false));
|
||||||
|
|
||||||
if (mixinMapFile.exists()) {
|
for (File mixinMapFile : extension.getAllMixinMappings()) {
|
||||||
remapperBuilder = remapperBuilder.withMappings(TinyUtils.createTinyMappingProvider(mixinMapPath, fromM, toM));
|
if (mixinMapFile.exists()) {
|
||||||
|
remapperBuilder = remapperBuilder.withMappings(TinyUtils.createTinyMappingProvider(mixinMapFile.toPath(), fromM, toM));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
project.getLogger().lifecycle(":remapping " + input.getFileName());
|
project.getLogger().lifecycle(":remapping " + input.getFileName());
|
||||||
|
@ -194,11 +193,10 @@ public class RemapJarTask extends Jar {
|
||||||
jarRemapper.addMappings(TinyRemapperMappingsHelper.create(mappingsProvider.getMappings(), fromM, toM, false));
|
jarRemapper.addMappings(TinyRemapperMappingsHelper.create(mappingsProvider.getMappings(), fromM, toM, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
File mixinMapFile = extension.getMixinMappings();
|
for (File mixinMapFile : extension.getAllMixinMappings()) {
|
||||||
Path mixinMapPath = mixinMapFile.toPath();
|
if (mixinMapFile.exists()) {
|
||||||
|
jarRemapper.addMappings(TinyUtils.createTinyMappingProvider(mixinMapFile.toPath(), fromM, toM));
|
||||||
if (mixinMapFile.exists()) {
|
}
|
||||||
jarRemapper.addMappings(TinyUtils.createTinyMappingProvider(mixinMapPath, fromM, toM));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jarRemapper.scheduleRemap(input, output)
|
jarRemapper.scheduleRemap(input, output)
|
||||||
|
|
|
@ -73,7 +73,7 @@ public abstract class AnnotationProcessorInvoker<T extends Task> {
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||||
Map<String, String> args = new HashMap<String, String>() {{
|
Map<String, String> args = new HashMap<String, String>() {{
|
||||||
put("inMapFileNamedIntermediary", extension.getMappingsProvider().tinyMappings.getCanonicalPath());
|
put("inMapFileNamedIntermediary", extension.getMappingsProvider().tinyMappings.getCanonicalPath());
|
||||||
put("outMapFileNamedIntermediary", extension.getMixinMappings().getCanonicalPath());
|
put("outMapFileNamedIntermediary", extension.getNextMixinMappings().getCanonicalPath());
|
||||||
put("outRefMapFile", getRefmapDestination(task, extension));
|
put("outRefMapFile", getRefmapDestination(task, extension));
|
||||||
put("defaultObfuscationEnv", "named:intermediary");
|
put("defaultObfuscationEnv", "named:intermediary");
|
||||||
}};
|
}};
|
||||||
|
|
Loading…
Reference in New Issue