You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Loom builds with a refmap equal to the conventional value for the property defaultRefmapName, and does not add refmap property to mixin configuration files when defaultRefmapName is set within an afterEvaluate.
When building, the refmap is produced by Mixin AP with the file name set by the convention of defaultRefmapName, equal to ${project.name}-refmap.json.
Later in the build (in remapJar), Loom attempts to add the refmap property to mixin configuration files. It resolves defaultRefmapName correctly as per the minimal reproduction above as test.refmap.json.
Before adding, Loom checks that the jar contains such refmap, this fails, since the name of the refmap differs.
which applies mixin AP to a sourceset, with the refmap name resolving defaultRefmapName
In remapJar, Loom adds the refmap property to mixin configs defined inside of fabric.mod.json.
Here is a snippet, I have added comments
publicvoidapplyToJar(Pathpath) throwsIOException {
// Get the fabric.mod.json from the `jar` task built jarfinalFabricModJsonfabricModJson = FabricModJsonFactory.createFromZipNullable(path);
if (fabricModJson == null) {
return;
}
// Get mixin configurations defined in the FMJfinalList<String> allMixinConfigs = fabricModJson.getMixinConfigurations();
// Gets mixin files that match a pattern from resourcesfinalList<String> mixinConfigs = getOptions().getMixinConfigs().get().stream()
.filter(allMixinConfigs::contains) // intersect with the ones in FMJ
.toList();
// This refmapName is resolved (property `defaultRefmapName`) in the// constructor of `RemapJar` where `getOptions()` property is set.finalStringrefmapName = getOptions().getRefmapName().get();
// This check fails, since the AP was told to generate a refmap with a // different name (the conventional name). The refmap is never added.if (ZipUtils.contains(path, refmapName)) {
inttransformed = ZipUtils.transformJson(JsonObject.class, path, mixinConfigs.stream().collect(Collectors.toMap(s -> s, s -> json -> {
if (!json.has("refmap")) {
json.addProperty("refmap", refmapName);
}
returnjson;
})));
}
}
To summarise
Loom resolves defaultRefmapName within an afterEvaluate, using it to tell the Mixin AP the name to generate the refmap
Loom resolves defaultRefmapName again at build-time within remapJar, to add it to mixin configuration files. It fails the check to see if the refmap exists in the jar, since it's been written as a different name.
This is a race condition between Loom's afterEvaluate and the buildscript's.
Potential fixes
Call finalizeOnRead() on defaultRefmapName, making this behaviour impossible
Move configuration of Mixin AP to later in the build lifecycle.
Something else I can't think of
The text was updated successfully, but these errors were encountered:
Minimal reproduction
The
afterEvaluate
is the issue here.Problem
Loom builds with a refmap equal to the conventional value for the property
defaultRefmapName
, and does not addrefmap
property to mixin configuration files whendefaultRefmapName
is set within anafterEvaluate
.defaultRefmapName
, equal to${project.name}-refmap.json
.remapJar
), Loom attempts to add therefmap
property to mixin configuration files. It resolvesdefaultRefmapName
correctly as per the minimal reproduction above astest.refmap.json
.Breaking it down
CompileConfiguration#run#afterEvaluationWithService
callsCompileConfiguration#setupMixinAp
MixinExtensionImpl#init
MixinExtensionImpl#initDefault
defaultRefmapName
In
remapJar
, Loom adds therefmap
property to mixin configs defined inside offabric.mod.json
.Here is a snippet, I have added comments
To summarise
defaultRefmapName
within anafterEvaluate
, using it to tell the Mixin AP the name to generate the refmapdefaultRefmapName
again at build-time withinremapJar
, to add it to mixin configuration files. It fails the check to see if the refmap exists in the jar, since it's been written as a different name.This is a race condition between Loom's
afterEvaluate
and the buildscript's.Potential fixes
finalizeOnRead()
ondefaultRefmapName
, making this behaviour impossibleThe text was updated successfully, but these errors were encountered: