mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Reduce scope of META-INF customizations to main, source, and javadoc jars
Closes gh-23955
This commit is contained in:
parent
49ea023a64
commit
1e100677c7
@ -18,6 +18,7 @@ package org.springframework.boot.build;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -106,19 +107,25 @@ class JavaConventions {
|
|||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
Set<String> javadocJarTaskNames = sourceSets.stream().map(SourceSet::getJavadocJarTaskName)
|
Set<String> javadocJarTaskNames = sourceSets.stream().map(SourceSet::getJavadocJarTaskName)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
project.getTasks().withType(Jar.class, (jar) -> project.afterEvaluate((evaluated) -> {
|
Set<String> jarTaskNames = sourceSets.stream().map(SourceSet::getJarTaskName).collect(Collectors.toSet());
|
||||||
jar.metaInf((metaInf) -> metaInf.from(extractLegalResources));
|
Set<String> jarTasksOfInterest = new HashSet<String>();
|
||||||
jar.manifest((manifest) -> {
|
jarTasksOfInterest.addAll(sourceJarTaskNames);
|
||||||
Map<String, Object> attributes = new TreeMap<>();
|
jarTasksOfInterest.addAll(javadocJarTaskNames);
|
||||||
attributes.put("Automatic-Module-Name", project.getName().replace("-", "."));
|
jarTasksOfInterest.addAll(jarTaskNames);
|
||||||
attributes.put("Build-Jdk-Spec", project.property("sourceCompatibility"));
|
project.getTasks().matching((task) -> jarTasksOfInterest.contains(task.getName())).withType(Jar.class,
|
||||||
attributes.put("Built-By", "Spring");
|
(jar) -> project.afterEvaluate((evaluated) -> {
|
||||||
attributes.put("Implementation-Title",
|
jar.metaInf((metaInf) -> metaInf.from(extractLegalResources));
|
||||||
determineImplementationTitle(project, sourceJarTaskNames, javadocJarTaskNames, jar));
|
jar.manifest((manifest) -> {
|
||||||
attributes.put("Implementation-Version", project.getVersion());
|
Map<String, Object> attributes = new TreeMap<>();
|
||||||
manifest.attributes(attributes);
|
attributes.put("Automatic-Module-Name", project.getName().replace("-", "."));
|
||||||
});
|
attributes.put("Build-Jdk-Spec", project.property("sourceCompatibility"));
|
||||||
}));
|
attributes.put("Built-By", "Spring");
|
||||||
|
attributes.put("Implementation-Title",
|
||||||
|
determineImplementationTitle(project, sourceJarTaskNames, javadocJarTaskNames, jar));
|
||||||
|
attributes.put("Implementation-Version", project.getVersion());
|
||||||
|
manifest.attributes(attributes);
|
||||||
|
});
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String determineImplementationTitle(Project project, Set<String> sourceJarTaskNames,
|
private String determineImplementationTitle(Project project, Set<String> sourceJarTaskNames,
|
||||||
|
Loading…
Reference in New Issue
Block a user