Sort extra manifest attributes (#958)

This commit is contained in:
haykam821
2023-10-15 05:45:46 -04:00
committed by modmuss
parent 46e27ce1ba
commit 78a903d2c9
2 changed files with 16 additions and 12 deletions

View File

@@ -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 abstract class JarManifestService implements BuildService<JarManifestServ
}
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());
@@ -94,10 +102,6 @@ public abstract class JarManifestService implements BuildService<JarManifestServ
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 { }