Skip to content

Commit 38821c1

Browse files
committed
Merge branch '2.3.x'
Closes gh-24057
2 parents d6f10e1 + 1e10067 commit 38821c1

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.io.File;
1919
import java.util.Arrays;
2020
import java.util.Collections;
21+
import java.util.HashSet;
2122
import java.util.List;
2223
import java.util.Map;
2324
import java.util.Set;
@@ -113,19 +114,25 @@ private void configureJarManifestConventions(Project project) {
113114
.collect(Collectors.toSet());
114115
Set<String> javadocJarTaskNames = sourceSets.stream().map(SourceSet::getJavadocJarTaskName)
115116
.collect(Collectors.toSet());
116-
project.getTasks().withType(Jar.class, (jar) -> project.afterEvaluate((evaluated) -> {
117-
jar.metaInf((metaInf) -> metaInf.from(extractLegalResources));
118-
jar.manifest((manifest) -> {
119-
Map<String, Object> attributes = new TreeMap<>();
120-
attributes.put("Automatic-Module-Name", project.getName().replace("-", "."));
121-
attributes.put("Build-Jdk-Spec", project.property("sourceCompatibility"));
122-
attributes.put("Built-By", "Spring");
123-
attributes.put("Implementation-Title",
124-
determineImplementationTitle(project, sourceJarTaskNames, javadocJarTaskNames, jar));
125-
attributes.put("Implementation-Version", project.getVersion());
126-
manifest.attributes(attributes);
127-
});
128-
}));
117+
Set<String> jarTaskNames = sourceSets.stream().map(SourceSet::getJarTaskName).collect(Collectors.toSet());
118+
Set<String> jarTasksOfInterest = new HashSet<String>();
119+
jarTasksOfInterest.addAll(sourceJarTaskNames);
120+
jarTasksOfInterest.addAll(javadocJarTaskNames);
121+
jarTasksOfInterest.addAll(jarTaskNames);
122+
project.getTasks().matching((task) -> jarTasksOfInterest.contains(task.getName())).withType(Jar.class,
123+
(jar) -> project.afterEvaluate((evaluated) -> {
124+
jar.metaInf((metaInf) -> metaInf.from(extractLegalResources));
125+
jar.manifest((manifest) -> {
126+
Map<String, Object> attributes = new TreeMap<>();
127+
attributes.put("Automatic-Module-Name", project.getName().replace("-", "."));
128+
attributes.put("Build-Jdk-Spec", project.property("sourceCompatibility"));
129+
attributes.put("Built-By", "Spring");
130+
attributes.put("Implementation-Title",
131+
determineImplementationTitle(project, sourceJarTaskNames, javadocJarTaskNames, jar));
132+
attributes.put("Implementation-Version", project.getVersion());
133+
manifest.attributes(attributes);
134+
});
135+
}));
129136
}
130137

131138
private String determineImplementationTitle(Project project, Set<String> sourceJarTaskNames,

0 commit comments

Comments
 (0)