mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +08:00
Note starters' and annotation processors' jar type in their manifest
See gh-22203
This commit is contained in:
parent
53607ea777
commit
be56cac2bb
@ -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"
|
||||
|
@ -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);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
@ -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<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> {
|
||||
(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> {
|
||||
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);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -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…
Reference in New Issue
Block a user