Add Fabric-Jar-Type to jar manifest.

Either 'classes' or 'sources', the idea is mod distribution platforms can check that sources jars are not uploaded accidentally.

Closes #939
This commit is contained in:
modmuss50
2023-09-11 11:47:19 +01:00
parent 1a4f76584f
commit 0b36121357
3 changed files with 14 additions and 0 deletions

View File

@@ -75,6 +75,7 @@ public abstract class AbstractRemapJarTask extends Jar {
public static final String MANIFEST_NAMESPACE_KEY = "Fabric-Mapping-Namespace";
public static final String MANIFEST_SPLIT_ENV_KEY = "Fabric-Loom-Split-Environment";
public static final String MANIFEST_CLIENT_ENTRIES_KEY = "Fabric-Loom-Client-Only-Entries";
public static final String MANIFEST_JAR_TYPE_KEY = "Fabric-Jar-Type";
public static final Attributes.Name MANIFEST_SPLIT_ENV_NAME = new Attributes.Name(MANIFEST_SPLIT_ENV_KEY);
public static final Attributes.Name MANIFEST_CLIENT_ENTRIES_NAME = new Attributes.Name(MANIFEST_CLIENT_ENTRIES_KEY);
@@ -112,6 +113,11 @@ public abstract class AbstractRemapJarTask extends Jar {
@Optional
public abstract Property<String> getClientOnlySourceSetName();
@Input
@Optional
@ApiStatus.Internal
public abstract Property<String> getJarType();
private final Provider<JarManifestService> jarManifestServiceProvider;
@Inject
@@ -120,6 +126,7 @@ public abstract class AbstractRemapJarTask extends Jar {
getTargetNamespace().convention(MappingsNamespace.INTERMEDIARY.toString()).finalizeValueOnRead();
getRemapperIsolation().convention(false).finalizeValueOnRead();
getIncludesClientOnlyClasses().convention(false).finalizeValueOnRead();
getJarType().finalizeValueOnRead();
jarManifestServiceProvider = JarManifestService.get(getProject());
usesService(jarManifestServiceProvider);
@@ -149,6 +156,10 @@ public abstract class AbstractRemapJarTask extends Jar {
params.getClientOnlyEntries().set(clientOnlyEntries.stream().filter(s -> s.endsWith(".class")).toList());
}
if (getJarType().isPresent()) {
params.getManifestAttributes().put(MANIFEST_JAR_TYPE_KEY, getJarType().get());
}
action.execute(params);
});
}