Skip to content

Commit

Permalink
Sort extra manifest attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
haykam821 committed Oct 10, 2023
1 parent b7c8013 commit 9efc729
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -74,12 +75,19 @@ public static synchronized Provider<JarManifestService> get(Project project) {
}

public void apply(Manifest manifest, Map<String, String> 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());
Expand All @@ -94,10 +102,6 @@ public void apply(Manifest manifest, Map<String, String> extraValues) {
attributes.putValue("Fabric-Mixin-Version", p.getMixinVersion().get().version());
attributes.putValue("Fabric-Mixin-Group", p.getMixinVersion().get().group());
}

for (Map.Entry<String, String> entry : extraValues.entrySet()) {
attributes.putValue(entry.getKey(), entry.getValue());
}
}

private record MixinVersion(String group, String version) implements Serializable { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}

Expand Down

0 comments on commit 9efc729

Please sign in to comment.