1616
1717package org .springframework .pulsar .gradle ;
1818
19- import java .util .Arrays ;
2019import java .util .Collections ;
21- import java .util .Map ;
2220import java .util .Set ;
23- import java .util .TreeMap ;
24- import java .util .stream .Collectors ;
2521
2622import org .gradle .api .Plugin ;
2723import org .gradle .api .Project ;
3430import org .gradle .api .plugins .quality .Checkstyle ;
3531import org .gradle .api .plugins .quality .CheckstyleExtension ;
3632import org .gradle .api .plugins .quality .CheckstylePlugin ;
37- import org .gradle .api .tasks .SourceSet ;
38- import org .gradle .api .tasks .SourceSetContainer ;
3933import org .gradle .api .tasks .bundling .Jar ;
4034import org .gradle .api .tasks .compile .JavaCompile ;
4135import org .gradle .api .tasks .javadoc .Javadoc ;
7771 * <li>Enable {@code unchecked}, {@code deprecation}, {@code rawtypes}, and {@code varags}
7872 * warnings
7973 * </ul>
80- * <li>{@link Jar} tasks are configured to produce jars with LICENSE.txt and NOTICE.txt
81- * files and the following manifest entries:
82- * <ul>
83- * <li>{@code Automatic-Module-Name}
84- * <li>{@code Build-Jdk-Spec}
85- * <li>{@code Built-By}
86- * <li>{@code Implementation-Title}
87- * <li>{@code Implementation-Version}
88- * </ul>
8974 * <li>{@code spring-pulsar-dependencies} is used for dependency management</li>
9075 * </ul>
9176 *
@@ -107,7 +92,6 @@ public void apply(Project project) {
10792 configureSpringJavaFormat (project );
10893 configureJavadocConventions (project );
10994 configureTestConventions (project );
110- configureJarManifestConventions (project );
11195 configureDependencyManagement (project );
11296 });
11397 }
@@ -162,32 +146,6 @@ private void configureTestConventions(Project project) {
162146 .add (JavaPlugin .TEST_RUNTIME_ONLY_CONFIGURATION_NAME , "org.junit.platform:junit-platform-launcher" ));
163147 }
164148
165- private void configureJarManifestConventions (Project project ) {
166- ExtractResources extractLegalResources = project .getTasks ().create ("extractLegalResources" ,
167- ExtractResources .class );
168- extractLegalResources .getDestinationDirectory ().set (project .getLayout ().getBuildDirectory ().dir ("legal" ));
169- extractLegalResources .setResourcesNames (Arrays .asList ("LICENSE.txt" , "NOTICE.txt" ));
170- extractLegalResources .property ("version" , project .getVersion ().toString ());
171- SourceSetContainer sourceSets = project .getExtensions ().getByType (SourceSetContainer .class );
172- Set <String > sourceJarTaskNames = sourceSets .stream ().map (SourceSet ::getSourcesJarTaskName )
173- .collect (Collectors .toSet ());
174- Set <String > javadocJarTaskNames = sourceSets .stream ().map (SourceSet ::getJavadocJarTaskName )
175- .collect (Collectors .toSet ());
176- project .getTasks ().withType (Jar .class , (jar ) -> project .afterEvaluate ((evaluated ) -> {
177- jar .metaInf ((metaInf ) -> metaInf .from (extractLegalResources ));
178- jar .manifest ((manifest ) -> {
179- Map <String , Object > attributes = new TreeMap <>();
180- attributes .put ("Automatic-Module-Name" , project .getName ().replace ("-" , "." ));
181- attributes .put ("Build-Jdk-Spec" , SOURCE_AND_TARGET_COMPATIBILITY );
182- attributes .put ("Built-By" , "Spring" );
183- attributes .put ("Implementation-Title" ,
184- determineImplementationTitle (project , sourceJarTaskNames , javadocJarTaskNames , jar ));
185- attributes .put ("Implementation-Version" , project .getVersion ());
186- manifest .attributes (attributes );
187- });
188- }));
189- }
190-
191149 private String determineImplementationTitle (Project project , Set <String > sourceJarTaskNames ,
192150 Set <String > javadocJarTaskNames , Jar jar ) {
193151 if (sourceJarTaskNames .contains (jar .getName ())) {
0 commit comments