Add Automatic-Module-Name to manifest file

This commit updates the build to add an `Automatic-Module-Name` entry
to the manifest of each published jar. The names follow a convention
where the hyphen is replaced by a dot:

* `spring-xml`: `spring.xml`
* `spring-ws-core`: `spring.ws.core`
* `spring-ws-security`: `spring.ws.security`
* `spring-ws-support`: `spring.ws.support`
* `spring-ws-test`: `spring.ws.test`

Closes gh-1208
This commit is contained in:
Stéphane Nicoll
2025-03-11 15:07:40 +01:00
parent 122def7e21
commit 5e0897c61d

View File

@@ -17,6 +17,7 @@
package org.springframework.ws.gradle.conventions;
import java.util.Map;
import java.util.TreeMap;
import io.spring.javaformat.gradle.SpringJavaFormatPlugin;
import org.gradle.api.JavaVersion;
@@ -79,11 +80,15 @@ class JavaPluginConventions {
}
private void configureJarManifest(Project project) {
project.getTasks()
.named("jar", Jar.class,
(jar) -> jar.manifest((manifest) -> manifest.attributes(Map.of("Build-Jdk-Spec",
JAVA_BASELINE.getMajorVersion(), "Built-By", "Spring", "Implementation-Title",
project.getDescription(), "Implementation-Version", project.getVersion()))));
project.getTasks().named("jar", Jar.class, (jar) -> jar.manifest((manifest) -> {
Map<String, Object> attributes = new TreeMap<>();
attributes.put("Automatic-Module-Name", project.getName().replace("-", "."));
attributes.put("Build-Jdk-Spec", JAVA_BASELINE.getMajorVersion());
attributes.put("Built-By", "Spring");
attributes.put("Implementation-Title", project.getDescription());
attributes.put("Implementation-Version", project.getVersion());
manifest.attributes(attributes);
}));
}
private void configureToolchain(Project project, JavaPluginExtension java) {