Browse Source

Note starters' and annotation processors' jar type in their manifest

See gh-22203
pull/23246/head
dreis2211 6 years ago committed by Andy Wilkinson
parent
commit
be56cac2bb
  1. 4
      buildSrc/build.gradle
  2. 46
      buildSrc/src/main/java/org/springframework/boot/build/processors/AnnotationProcessorPlugin.java
  3. 16
      buildSrc/src/main/java/org/springframework/boot/build/starters/StarterPlugin.java
  4. 1
      spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/build.gradle
  5. 1
      spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/build.gradle

4
buildSrc/build.gradle

@ -38,6 +38,10 @@ checkstyle { @@ -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"

46
buildSrc/src/main/java/org/springframework/boot/build/processors/AnnotationProcessorPlugin.java

@ -0,0 +1,46 @@ @@ -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<Project> {
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<String, Object> attributes = new TreeMap<>();
attributes.put("Spring-Boot-Jar-Type", JAR_TYPE);
manifest.attributes(attributes);
});
}));
}
}

16
buildSrc/src/main/java/org/springframework/boot/build/starters/StarterPlugin.java

@ -17,6 +17,8 @@ @@ -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; @@ -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; @@ -40,6 +43,8 @@ import org.springframework.util.StringUtils;
*/
public class StarterPlugin implements Plugin<Project> {
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<Project> { @@ -57,6 +62,7 @@ public class StarterPlugin implements Plugin<Project> {
(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> { @@ -75,4 +81,14 @@ public class StarterPlugin implements Plugin<Project> {
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<String, Object> attributes = new TreeMap<>();
attributes.put("Spring-Boot-Jar-Type", JAR_TYPE);
manifest.attributes(attributes);
});
}));
}
}

1
spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/build.gradle

@ -2,6 +2,7 @@ plugins { @@ -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"

1
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/build.gradle

@ -2,6 +2,7 @@ plugins { @@ -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"

Loading…
Cancel
Save