|
18 | 18 | import java.io.File;
|
19 | 19 | import java.util.Arrays;
|
20 | 20 | import java.util.Collections;
|
| 21 | +import java.util.HashSet; |
21 | 22 | import java.util.List;
|
22 | 23 | import java.util.Map;
|
23 | 24 | import java.util.Set;
|
@@ -106,19 +107,25 @@ private void configureJarManifestConventions(Project project) {
|
106 | 107 | .collect(Collectors.toSet());
|
107 | 108 | Set<String> javadocJarTaskNames = sourceSets.stream().map(SourceSet::getJavadocJarTaskName)
|
108 | 109 | .collect(Collectors.toSet());
|
109 |
| - project.getTasks().withType(Jar.class, (jar) -> project.afterEvaluate((evaluated) -> { |
110 |
| - jar.metaInf((metaInf) -> metaInf.from(extractLegalResources)); |
111 |
| - jar.manifest((manifest) -> { |
112 |
| - Map<String, Object> attributes = new TreeMap<>(); |
113 |
| - attributes.put("Automatic-Module-Name", project.getName().replace("-", ".")); |
114 |
| - attributes.put("Build-Jdk-Spec", project.property("sourceCompatibility")); |
115 |
| - attributes.put("Built-By", "Spring"); |
116 |
| - attributes.put("Implementation-Title", |
117 |
| - determineImplementationTitle(project, sourceJarTaskNames, javadocJarTaskNames, jar)); |
118 |
| - attributes.put("Implementation-Version", project.getVersion()); |
119 |
| - manifest.attributes(attributes); |
120 |
| - }); |
121 |
| - })); |
| 110 | + Set<String> jarTaskNames = sourceSets.stream().map(SourceSet::getJarTaskName).collect(Collectors.toSet()); |
| 111 | + Set<String> jarTasksOfInterest = new HashSet<String>(); |
| 112 | + jarTasksOfInterest.addAll(sourceJarTaskNames); |
| 113 | + jarTasksOfInterest.addAll(javadocJarTaskNames); |
| 114 | + jarTasksOfInterest.addAll(jarTaskNames); |
| 115 | + project.getTasks().matching((task) -> jarTasksOfInterest.contains(task.getName())).withType(Jar.class, |
| 116 | + (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 | + })); |
122 | 129 | }
|
123 | 130 |
|
124 | 131 | private String determineImplementationTitle(Project project, Set<String> sourceJarTaskNames,
|
|
0 commit comments