From 93ea62a961eb28fd477422938a98f80549f63442 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 7 Sep 2024 22:10:26 +0900 Subject: [PATCH 1/6] Only validate loom version when mixins are to be remapped with TinyRemapper --- .../net/fabricmc/loom/configuration/mods/ArtifactMetadata.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/fabricmc/loom/configuration/mods/ArtifactMetadata.java b/src/main/java/net/fabricmc/loom/configuration/mods/ArtifactMetadata.java index 6fc3ac755..4ee3c72d8 100644 --- a/src/main/java/net/fabricmc/loom/configuration/mods/ArtifactMetadata.java +++ b/src/main/java/net/fabricmc/loom/configuration/mods/ArtifactMetadata.java @@ -81,7 +81,7 @@ public static ArtifactMetadata create(ArtifactRef artifact, String currentLoomVe } } - if (loomVersion != null && refmapRemapType != MixinRemapType.STATIC) { + if (loomVersion != null && refmapRemapType == MixinRemapType.STATIC) { validateLoomVersion(loomVersion, currentLoomVersion); } From f433315b5307bd8c76bac757242a615360c26e12 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 7 Sep 2024 22:37:50 +0900 Subject: [PATCH 2/6] add tests --- .../test/unit/ArtifactMetadataTest.groovy | 45 ++++++++++++++++--- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/src/test/groovy/net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy b/src/test/groovy/net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy index 9528d87f9..189767cb5 100644 --- a/src/test/groovy/net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy @@ -116,14 +116,15 @@ class ArtifactMetadataTest extends Specification { type | entries MIXIN | ["hello.json": "{}"] // None Mod jar MIXIN | ["fabric.mod.json": "{}"] // Fabric mod without manfiest file - MIXIN | ["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest("Fabric-Loom-Mixin-Remap-Type", "mixin")] // Fabric mod without remap type entry - STATIC | ["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest("Fabric-Loom-Mixin-Remap-Type", "static")] // Fabric mod opt-in + MIXIN | ["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest("Fabric-Loom-Remap", "true")] // Fabric mod without remap type entry + MIXIN | ["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest("Fabric-Loom-Mixin-Remap-Type", "mixin")] // Fabric mod with remap type entry "mixin" + STATIC | ["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest("Fabric-Loom-Mixin-Remap-Type", "static")] // Fabric mod with remap type entry "static" } // Test that a mod with the same or older version of loom can be read def "Valid loom version"() { given: - def zip = createMod(modLoomVersion, "mixin") + def zip = createModWithRemapType(modLoomVersion, "mixin") when: def metadata = createMetadata(zip, loomVersion) then: @@ -144,7 +145,7 @@ class ArtifactMetadataTest extends Specification { // Test that a mod with the same or older version of loom can be read def "Invalid loom version"() { given: - def zip = createMod(modLoomVersion, "mixin") + def zip = createModWithRemapType(modLoomVersion, "mixin") when: def metadata = createMetadata(zip, loomVersion) then: @@ -158,9 +159,35 @@ class ArtifactMetadataTest extends Specification { "1.4" | "2.4" } - def "Accepts all Loom versions"() { + def "Accepts all Loom versions for remap 'false'"() { given: - def zip = createMod(modLoomVersion, "static") + def zip = createModWithRemap(modLoomVersion, false) + when: + def metadata = createMetadata(zip, loomVersion) + then: + metadata != null + where: + loomVersion | modLoomVersion + // Valid + "1.4" | "1.0.1" + "1.4" | "1.0.99" + "1.4" | "1.4" + "1.4" | "1.4.0" + "1.4" | "1.4.1" + "1.4" | "1.4.99" + "1.4" | "1.4.local" + "1.5" | "1.4.99" + "2.0" | "1.4.99" + // Usually invalid + "1.4" | "1.5" + "1.4" | "1.5.00" + "1.4" | "2.0" + "1.4" | "2.4" + } + + def "Accepts all Loom versions for remap 'true'"() { + given: + def zip = createModWithRemap(modLoomVersion, true) when: def metadata = createMetadata(zip, loomVersion) then: @@ -201,10 +228,14 @@ class ArtifactMetadataTest extends Specification { ] | ["META-INF/MANIFEST.MF": manifest("Fabric-Loom-Known-Indy-BSMS", "com/example/Class,com/example/Another")] // two bsms } - private static Path createMod(String loomVersion, String remapType) { + private static Path createModWithRemapType(String loomVersion, String remapType) { return createZip(["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest(["Fabric-Loom-Version": loomVersion, "Fabric-Loom-Mixin-Remap-Type": remapType])]) } + private static Path createModWithRemap(String loomVersion, boolean remap) { + return createZip(["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest(["Fabric-Loom-Version": loomVersion, "Fabric-Loom-Mixin-Remap": remap ? "true" : "false"])]) + } + private static ArtifactMetadata createMetadata(Path zip, String loomVersion = "1.4") { return ArtifactMetadata.create(createArtifact(zip), loomVersion) } From 1d90f87f2882e4c4e461e16a2f3c6aa12e9d6951 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 7 Sep 2024 22:41:01 +0900 Subject: [PATCH 3/6] change existing test to match new logic --- .../net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/groovy/net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy b/src/test/groovy/net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy index 189767cb5..6bbf67b49 100644 --- a/src/test/groovy/net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy @@ -145,7 +145,7 @@ class ArtifactMetadataTest extends Specification { // Test that a mod with the same or older version of loom can be read def "Invalid loom version"() { given: - def zip = createModWithRemapType(modLoomVersion, "mixin") + def zip = createModWithRemapType(modLoomVersion, "static") when: def metadata = createMetadata(zip, loomVersion) then: From 0b831d5ab5cacf3c04943fe6f40ef52d869b2b8e Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 7 Sep 2024 22:43:15 +0900 Subject: [PATCH 4/6] update "Valid loom version" test --- .../net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/groovy/net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy b/src/test/groovy/net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy index 6bbf67b49..c008d25d3 100644 --- a/src/test/groovy/net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy @@ -124,7 +124,7 @@ class ArtifactMetadataTest extends Specification { // Test that a mod with the same or older version of loom can be read def "Valid loom version"() { given: - def zip = createModWithRemapType(modLoomVersion, "mixin") + def zip = createModWithRemapType(modLoomVersion, "static") when: def metadata = createMetadata(zip, loomVersion) then: From 38e08c23bca51cbab075a04275aa4274b1b55032 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 7 Sep 2024 23:11:31 +0900 Subject: [PATCH 5/6] tabs for indentation, spaces for alignment --- .../loom/test/unit/ArtifactMetadataTest.groovy | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/test/groovy/net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy b/src/test/groovy/net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy index c008d25d3..6054e6e55 100644 --- a/src/test/groovy/net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy @@ -114,11 +114,11 @@ class ArtifactMetadataTest extends Specification { result == type where: type | entries - MIXIN | ["hello.json": "{}"] // None Mod jar - MIXIN | ["fabric.mod.json": "{}"] // Fabric mod without manfiest file + MIXIN | ["hello.json": "{}"] // None Mod jar + MIXIN | ["fabric.mod.json": "{}"] // Fabric mod without manfiest file MIXIN | ["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest("Fabric-Loom-Remap", "true")] // Fabric mod without remap type entry MIXIN | ["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest("Fabric-Loom-Mixin-Remap-Type", "mixin")] // Fabric mod with remap type entry "mixin" - STATIC | ["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest("Fabric-Loom-Mixin-Remap-Type", "static")] // Fabric mod with remap type entry "static" + STATIC | ["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest("Fabric-Loom-Mixin-Remap-Type", "static")] // Fabric mod with remap type entry "static" } // Test that a mod with the same or older version of loom can be read @@ -138,8 +138,8 @@ class ArtifactMetadataTest extends Specification { "1.4" | "1.4.1" "1.4" | "1.4.99" "1.4" | "1.4.local" - "1.5" | "1.4.99" - "2.0" | "1.4.99" + "1.5" | "1.4.99" + "2.0" | "1.4.99" } // Test that a mod with the same or older version of loom can be read @@ -176,8 +176,8 @@ class ArtifactMetadataTest extends Specification { "1.4" | "1.4.1" "1.4" | "1.4.99" "1.4" | "1.4.local" - "1.5" | "1.4.99" - "2.0" | "1.4.99" + "1.5" | "1.4.99" + "2.0" | "1.4.99" // Usually invalid "1.4" | "1.5" "1.4" | "1.5.00" @@ -202,8 +202,8 @@ class ArtifactMetadataTest extends Specification { "1.4" | "1.4.1" "1.4" | "1.4.99" "1.4" | "1.4.local" - "1.5" | "1.4.99" - "2.0" | "1.4.99" + "1.5" | "1.4.99" + "2.0" | "1.4.99" // Usually invalid "1.4" | "1.5" "1.4" | "1.5.00" From 9bedf1cb918457744d95f2a8d249421145966915 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 7 Sep 2024 23:14:53 +0900 Subject: [PATCH 6/6] fix more sneaky tabs --- .../net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/groovy/net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy b/src/test/groovy/net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy index 6054e6e55..3dbfbb7ec 100644 --- a/src/test/groovy/net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/unit/ArtifactMetadataTest.groovy @@ -117,8 +117,8 @@ class ArtifactMetadataTest extends Specification { MIXIN | ["hello.json": "{}"] // None Mod jar MIXIN | ["fabric.mod.json": "{}"] // Fabric mod without manfiest file MIXIN | ["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest("Fabric-Loom-Remap", "true")] // Fabric mod without remap type entry - MIXIN | ["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest("Fabric-Loom-Mixin-Remap-Type", "mixin")] // Fabric mod with remap type entry "mixin" - STATIC | ["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest("Fabric-Loom-Mixin-Remap-Type", "static")] // Fabric mod with remap type entry "static" + MIXIN | ["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest("Fabric-Loom-Mixin-Remap-Type", "mixin")] // Fabric mod with remap type entry "mixin" + STATIC | ["fabric.mod.json": "{}", "META-INF/MANIFEST.MF": manifest("Fabric-Loom-Mixin-Remap-Type", "static")] // Fabric mod with remap type entry "static" } // Test that a mod with the same or older version of loom can be read