Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort extra manifest attributes #958

Merged
merged 1 commit into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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