From 9efc729aced4981d9d8a571ac434eb84d017b113 Mon Sep 17 00:00:00 2001 From: haykam821 <24855774+haykam821@users.noreply.github.com> Date: Tue, 10 Oct 2023 13:01:36 -0400 Subject: [PATCH] Sort extra manifest attributes --- .../loom/task/service/JarManifestService.java | 16 ++++++++++------ .../integration/ReproducibleBuildTest.groovy | 12 ++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/net/fabricmc/loom/task/service/JarManifestService.java b/src/main/java/net/fabricmc/loom/task/service/JarManifestService.java index 4ca2791c0..5b86fbc8a 100644 --- a/src/main/java/net/fabricmc/loom/task/service/JarManifestService.java +++ b/src/main/java/net/fabricmc/loom/task/service/JarManifestService.java @@ -25,6 +25,7 @@ package net.fabricmc.loom.task.service; import java.io.Serializable; +import java.util.Comparator; import java.util.Map; import java.util.Optional; import java.util.jar.Attributes; @@ -74,12 +75,19 @@ public static synchronized Provider get(Project project) { } public void apply(Manifest manifest, Map extraValues) { - // Don't set when running the reproducible build tests as it will break them when anything updates + Attributes attributes = manifest.getMainAttributes(); + + extraValues.entrySet().stream() + .sorted(Comparator.comparing(Map.Entry::getKey)) + .forEach(entry -> { + attributes.putValue(entry.getKey(), entry.getValue()); + }); + + // Don't set version attributes when running the reproducible build tests as it will break them when anything updates if (Boolean.getBoolean("loom.test.reproducible")) { return; } - Attributes attributes = manifest.getMainAttributes(); Params p = getParameters(); attributes.putValue("Fabric-Gradle-Version", p.getGradleVersion().get()); @@ -94,10 +102,6 @@ public void apply(Manifest manifest, Map extraValues) { attributes.putValue("Fabric-Mixin-Version", p.getMixinVersion().get().version()); attributes.putValue("Fabric-Mixin-Group", p.getMixinVersion().get().group()); } - - for (Map.Entry entry : extraValues.entrySet()) { - attributes.putValue(entry.getKey(), entry.getValue()); - } } private record MixinVersion(String group, String version) implements Serializable { } diff --git a/src/test/groovy/net/fabricmc/loom/test/integration/ReproducibleBuildTest.groovy b/src/test/groovy/net/fabricmc/loom/test/integration/ReproducibleBuildTest.groovy index 0936f58f7..d8e6a1ee5 100644 --- a/src/test/groovy/net/fabricmc/loom/test/integration/ReproducibleBuildTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/integration/ReproducibleBuildTest.groovy @@ -55,13 +55,13 @@ class ReproducibleBuildTest extends Specification implements GradleProjectTestTr where: version | modHash | sourceHash - DEFAULT_GRADLE | "97240b42385adfaa1952e9c4ea942f71" | [ - "61438feb9bd548788bbc637637d202fc", - "185ad8396d89b726064682bf22572036" + DEFAULT_GRADLE | "4bb8acb5e575a4080a8fe1282f8e1994" | [ + "8e8fac2a5e32fc872e6cf0f9ccc55cfd", + "ed331b6fae5677797a0104eba014e255" ] - PRE_RELEASE_GRADLE | "97240b42385adfaa1952e9c4ea942f71" | [ - "61438feb9bd548788bbc637637d202fc", - "185ad8396d89b726064682bf22572036" + PRE_RELEASE_GRADLE | "4bb8acb5e575a4080a8fe1282f8e1994" | [ + "8e8fac2a5e32fc872e6cf0f9ccc55cfd", + "ed331b6fae5677797a0104eba014e255" ] }