diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 4dd42090a95..bb87bbf6970 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -38,6 +38,10 @@ checkstyle { gradlePlugin { plugins { + annotationProcessorPlugin { + id = "org.springframework.boot.annotation-processor" + implementationClass = "org.springframework.boot.build.processors.AnnotationProcessorPlugin" + } autoConfigurationPlugin { id = "org.springframework.boot.auto-configuration" implementationClass = "org.springframework.boot.build.autoconfigure.AutoConfigurationPlugin" diff --git a/buildSrc/src/main/java/org/springframework/boot/build/processors/AnnotationProcessorPlugin.java b/buildSrc/src/main/java/org/springframework/boot/build/processors/AnnotationProcessorPlugin.java new file mode 100644 index 00000000000..cc2168c55dd --- /dev/null +++ b/buildSrc/src/main/java/org/springframework/boot/build/processors/AnnotationProcessorPlugin.java @@ -0,0 +1,46 @@ +/* + * Copyright 2019-2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.build.processors; + +import java.util.Map; +import java.util.TreeMap; + +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.tasks.bundling.Jar; + +/** + * A {@link Plugin} for an annotation processor project. + * + * @author Christoph Dreis + */ +public class AnnotationProcessorPlugin implements Plugin { + + private static final String JAR_TYPE = "annotation-processor"; + + @Override + public void apply(Project project) { + project.getTasks().withType(Jar.class, (jar) -> project.afterEvaluate((evaluated) -> { + jar.manifest((manifest) -> { + Map attributes = new TreeMap<>(); + attributes.put("Spring-Boot-Jar-Type", JAR_TYPE); + manifest.attributes(attributes); + }); + })); + } + +} diff --git a/buildSrc/src/main/java/org/springframework/boot/build/starters/StarterPlugin.java b/buildSrc/src/main/java/org/springframework/boot/build/starters/StarterPlugin.java index 76a9867f290..2e62b46018e 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/starters/StarterPlugin.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/starters/StarterPlugin.java @@ -17,6 +17,8 @@ package org.springframework.boot.build.starters; import java.io.File; +import java.util.Map; +import java.util.TreeMap; import org.gradle.api.Plugin; import org.gradle.api.Project; @@ -26,6 +28,7 @@ import org.gradle.api.plugins.JavaBasePlugin; import org.gradle.api.plugins.JavaLibraryPlugin; import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.PluginContainer; +import org.gradle.api.tasks.bundling.Jar; import org.springframework.boot.build.ConventionsPlugin; import org.springframework.boot.build.DeployedPlugin; @@ -40,6 +43,8 @@ import org.springframework.util.StringUtils; */ public class StarterPlugin implements Plugin { + private static final String JAR_TYPE = "dependencies-starter"; + @Override public void apply(Project project) { PluginContainer plugins = project.getPlugins(); @@ -57,6 +62,7 @@ public class StarterPlugin implements Plugin { (artifact) -> artifact.builtBy(starterMetadata)); createClasspathConflictsCheck(runtimeClasspath, project); createProhibitedDependenciesCheck(runtimeClasspath, project); + configureJarManifest(project); } private void createClasspathConflictsCheck(Configuration classpath, Project project) { @@ -75,4 +81,14 @@ public class StarterPlugin implements Plugin { project.getTasks().getByName(JavaBasePlugin.CHECK_TASK_NAME).dependsOn(checkClasspathForProhibitedDependencies); } + private void configureJarManifest(Project project) { + project.getTasks().withType(Jar.class, (jar) -> project.afterEvaluate((evaluated) -> { + jar.manifest((manifest) -> { + Map attributes = new TreeMap<>(); + attributes.put("Spring-Boot-Jar-Type", JAR_TYPE); + manifest.attributes(attributes); + }); + })); + } + } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/build.gradle index 800916d04d5..c131957b745 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/build.gradle @@ -2,6 +2,7 @@ plugins { id "java-library" id "org.springframework.boot.conventions" id "org.springframework.boot.deployed" + id "org.springframework.boot.annotation-processor" } description = "Spring Boot AutoConfigure Annotation Processor" diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/build.gradle index 00011483470..bcd85c1ecea 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/build.gradle @@ -2,6 +2,7 @@ plugins { id "java-library" id "org.springframework.boot.conventions" id "org.springframework.boot.deployed" + id "org.springframework.boot.annotation-processor" } description = "Spring Boot Configuration Annotation Processor"