-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Mixin Remapping for reobf tasks added by users (#197)
- Loading branch information
Showing
5 changed files
with
74 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/test/java/net/neoforged/moddevgradle/legacyforge/dsl/MixinMappingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package net.neoforged.moddevgradle.legacyforge.dsl; | ||
|
||
import net.neoforged.moddevgradle.internal.utils.ExtensionUtils; | ||
import net.neoforged.moddevgradle.legacyforge.internal.LegacyForgeModDevPlugin; | ||
import net.neoforged.moddevgradle.legacyforge.tasks.RemapJar; | ||
import org.gradle.jvm.tasks.Jar; | ||
import org.gradle.testfixtures.ProjectBuilder; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class MixinMappingTest { | ||
/** | ||
* Tests that we expect the Mixin AP to create for each refmap is added to the reobfuscation tasks | ||
* (both the default reobfJar and custom ones). | ||
*/ | ||
@Test | ||
public void testMixinMappingsArePropagatedToObfuscationTasks() { | ||
var project = ProjectBuilder.builder().build(); | ||
project.getPlugins().apply(LegacyForgeModDevPlugin.class); | ||
|
||
var obfuscation = ExtensionUtils.getExtension(project, "obfuscation", Obfuscation.class); | ||
var sourceSets = ExtensionUtils.getSourceSets(project); | ||
var mixinExtension = ExtensionUtils.getExtension(project, "mixin", MixinExtension.class); | ||
var mainSourceSet = sourceSets.getByName("main"); | ||
mixinExtension.add(mainSourceSet, "testmod.refmap.json"); | ||
|
||
var someJarTask = project.getTasks().register("someJar", Jar.class); | ||
var customRemapJarTask = obfuscation.reobfuscate(someJarTask, mainSourceSet).get(); | ||
var remapJarTask = (RemapJar) project.getTasks().getByName("reobfJar"); | ||
|
||
// The main named->intermediary mappings for the game | ||
var namedToIntermediary = project.getLayout().getBuildDirectory().file("moddev/namedToIntermediate.tsrg").get().getAsFile(); | ||
var mixinApMappings = project.getLayout().getBuildDirectory().file("mixin/testmod.refmap.json.mappings.tsrg").get().getAsFile(); | ||
|
||
// The mapping file produced by the Mixin AP should be added as an input to both Jar tasks. | ||
var otherMappings = customRemapJarTask.getRemapOperation().getMappings().getFiles(); | ||
assertThat(otherMappings).containsOnly(namedToIntermediary, mixinApMappings); | ||
var mappings = remapJarTask.getRemapOperation().getMappings().getFiles(); | ||
assertThat(mappings).containsOnly(namedToIntermediary, mixinApMappings); | ||
} | ||
} |