Skip to content

Commit 2cdf434

Browse files
committed
Merge branch '3.4.x' into 3.5.x
Closes gh-46631
2 parents f3aa428 + c9c8076 commit 2cdf434

File tree

8 files changed

+164
-33
lines changed

8 files changed

+164
-33
lines changed

buildSrc/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ configurations.all {
8484

8585
gradlePlugin {
8686
plugins {
87+
aggregatorPlugin {
88+
id = "org.springframework.boot.aggregator"
89+
implementationClass = "org.springframework.boot.build.aggregation.AggregatorPlugin"
90+
}
8791
annotationProcessorPlugin {
8892
id = "org.springframework.boot.annotation-processor"
8993
implementationClass = "org.springframework.boot.build.processors.AnnotationProcessorPlugin"
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.build.aggregation;
18+
19+
import org.gradle.api.Named;
20+
import org.gradle.api.attributes.Category;
21+
import org.gradle.api.attributes.Usage;
22+
import org.gradle.api.file.ConfigurableFileCollection;
23+
import org.gradle.api.provider.Property;
24+
25+
/**
26+
* An aggregate.
27+
*
28+
* @author Andy Wilkinson
29+
*/
30+
public interface Aggregate extends Named {
31+
32+
/**
33+
* The {@link Category} used to select the variant that's included in the aggregate.
34+
* @return the category
35+
*/
36+
Property<String> getCategory();
37+
38+
/**
39+
* The {@link Usage} used to select the variant that's included in the aggregate.
40+
* @return the usage
41+
*/
42+
Property<String> getUsage();
43+
44+
/**
45+
* The aggregated files.
46+
* @return the aggregated files
47+
*/
48+
ConfigurableFileCollection getFiles();
49+
50+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.build.aggregation;
18+
19+
import org.gradle.api.NamedDomainObjectContainer;
20+
import org.gradle.api.NamedDomainObjectProvider;
21+
import org.gradle.api.Plugin;
22+
import org.gradle.api.Project;
23+
import org.gradle.api.artifacts.Configuration;
24+
import org.gradle.api.artifacts.DependencyScopeConfiguration;
25+
import org.gradle.api.artifacts.ResolvableConfiguration;
26+
import org.gradle.api.attributes.Category;
27+
import org.gradle.api.attributes.Usage;
28+
import org.gradle.api.model.ObjectFactory;
29+
30+
/**
31+
* {@link Plugin} for aggregating the output of other projects.
32+
*
33+
* @author Andy Wilkinson
34+
*/
35+
public class AggregatorPlugin implements Plugin<Project> {
36+
37+
@Override
38+
public void apply(Project target) {
39+
NamedDomainObjectContainer<Aggregate> aggregates = target.getObjects().domainObjectContainer(Aggregate.class);
40+
target.getExtensions().add("aggregates", aggregates);
41+
aggregates.all((aggregate) -> {
42+
NamedDomainObjectProvider<DependencyScopeConfiguration> dependencies = target.getConfigurations()
43+
.dependencyScope(aggregate.getName() + "Dependencies",
44+
(configuration) -> configureAttributes(configuration, aggregate, target.getObjects()));
45+
NamedDomainObjectProvider<ResolvableConfiguration> aggregated = target.getConfigurations()
46+
.resolvable(aggregate.getName(), (configuration) -> {
47+
configuration.extendsFrom(dependencies.get());
48+
configureAttributes(configuration, aggregate, target.getObjects());
49+
});
50+
target.getRootProject()
51+
.allprojects((project) -> target.getDependencies().add(dependencies.getName(), project));
52+
aggregate.getFiles()
53+
.convention(aggregated.map((configuration) -> configuration.getIncoming()
54+
.artifactView((view) -> view.setLenient(true))
55+
.getFiles()));
56+
});
57+
}
58+
59+
private void configureAttributes(Configuration configuration, Aggregate aggregate, ObjectFactory objects) {
60+
configuration.attributes((attributes) -> {
61+
attributes.attributeProvider(Category.CATEGORY_ATTRIBUTE,
62+
aggregate.getCategory().map((category) -> objects.named(Category.class, category)));
63+
attributes.attributeProvider(Usage.USAGE_ATTRIBUTE,
64+
aggregate.getUsage().map((usage) -> objects.named(Usage.class, usage)));
65+
});
66+
67+
}
68+
69+
}

buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/AutoConfigurationMetadata.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ public abstract class AutoConfigurationMetadata extends DefaultTask {
6161
private FileCollection classesDirectories;
6262

6363
public AutoConfigurationMetadata() {
64-
getProject().getConfigurations()
65-
.maybeCreate(AutoConfigurationPlugin.AUTO_CONFIGURATION_METADATA_CONFIGURATION_NAME);
6664
this.moduleName = getProject().getName();
6765
}
6866

buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/AutoConfigurationPlugin.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import org.gradle.api.artifacts.Configuration;
2727
import org.gradle.api.artifacts.ConfigurationContainer;
2828
import org.gradle.api.artifacts.Dependency;
29+
import org.gradle.api.attributes.Category;
30+
import org.gradle.api.attributes.Usage;
2931
import org.gradle.api.plugins.JavaBasePlugin;
3032
import org.gradle.api.plugins.JavaPlugin;
3133
import org.gradle.api.plugins.JavaPluginExtension;
@@ -53,11 +55,7 @@
5355
*/
5456
public class AutoConfigurationPlugin implements Plugin<Project> {
5557

56-
/**
57-
* Name of the {@link Configuration} that holds the auto-configuration metadata
58-
* artifact.
59-
*/
60-
public static final String AUTO_CONFIGURATION_METADATA_CONFIGURATION_NAME = "autoConfigurationMetadata";
58+
private static final String AUTO_CONFIGURATION_METADATA_CONFIGURATION_NAME = "autoConfigurationMetadata";
6159

6260
@Override
6361
public void apply(Project project) {
@@ -83,6 +81,14 @@ void configure() {
8381
addAnnotationProcessorsDependencies();
8482
TaskContainer tasks = this.project.getTasks();
8583
ConfigurationContainer configurations = this.project.getConfigurations();
84+
configurations.consumable(AUTO_CONFIGURATION_METADATA_CONFIGURATION_NAME, (configuration) -> {
85+
configuration.attributes((attributes) -> {
86+
attributes.attribute(Category.CATEGORY_ATTRIBUTE,
87+
this.project.getObjects().named(Category.class, Category.DOCUMENTATION));
88+
attributes.attribute(Usage.USAGE_ATTRIBUTE,
89+
this.project.getObjects().named(Usage.class, "auto-configuration-metadata"));
90+
});
91+
});
8692
tasks.register("autoConfigurationMetadata", AutoConfigurationMetadata.class,
8793
this::configureAutoConfigurationMetadata);
8894
TaskProvider<CheckAutoConfigurationImports> checkAutoConfigurationImports = tasks.register(

buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/DocumentAutoConfigurationClasses.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import org.gradle.api.file.FileCollection;
3737
import org.gradle.api.tasks.InputFiles;
3838
import org.gradle.api.tasks.OutputDirectory;
39+
import org.gradle.api.tasks.PathSensitive;
40+
import org.gradle.api.tasks.PathSensitivity;
3941
import org.gradle.api.tasks.TaskAction;
4042

4143
import org.springframework.util.StringUtils;
@@ -50,6 +52,7 @@ public abstract class DocumentAutoConfigurationClasses extends DefaultTask {
5052
private FileCollection autoConfiguration;
5153

5254
@InputFiles
55+
@PathSensitive(PathSensitivity.RELATIVE)
5356
public FileCollection getAutoConfiguration() {
5457
return this.autoConfiguration;
5558
}

buildSrc/src/main/java/org/springframework/boot/build/context/properties/ConfigurationPropertiesPlugin.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import org.gradle.api.Project;
2424
import org.gradle.api.Task;
2525
import org.gradle.api.artifacts.Configuration;
26+
import org.gradle.api.attributes.Category;
27+
import org.gradle.api.attributes.Usage;
2628
import org.gradle.api.file.RegularFile;
2729
import org.gradle.api.plugins.JavaPlugin;
2830
import org.gradle.api.plugins.JavaPluginExtension;
@@ -56,11 +58,7 @@
5658
*/
5759
public class ConfigurationPropertiesPlugin implements Plugin<Project> {
5860

59-
/**
60-
* Name of the {@link Configuration} that holds the configuration property metadata
61-
* artifact.
62-
*/
63-
public static final String CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME = "configurationPropertiesMetadata";
61+
private static final String CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME = "configurationPropertiesMetadata";
6462

6563
/**
6664
* Name of the {@link CheckAdditionalSpringConfigurationMetadata} task.
@@ -108,7 +106,15 @@ private void addMetadataArtifact(Project project) {
108106
.getByType(JavaPluginExtension.class)
109107
.getSourceSets()
110108
.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
111-
project.getConfigurations().maybeCreate(CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME);
109+
project.getConfigurations()
110+
.consumable(CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME, (configuration) -> {
111+
configuration.attributes((attributes) -> {
112+
attributes.attribute(Category.CATEGORY_ATTRIBUTE,
113+
project.getObjects().named(Category.class, Category.DOCUMENTATION));
114+
attributes.attribute(Usage.USAGE_ATTRIBUTE,
115+
project.getObjects().named(Usage.class, "configuration-properties-metadata"));
116+
});
117+
});
112118
project.afterEvaluate((evaluatedProject) -> evaluatedProject.getArtifacts()
113119
.add(CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME,
114120
mainSourceSet.getJava()

spring-boot-project/spring-boot-docs/build.gradle

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,16 @@ plugins {
2020
id "dev.adamko.dokkatoo-html"
2121
id "java"
2222
id "org.antora"
23+
id "org.jetbrains.kotlin.jvm"
24+
id "org.springframework.boot.aggregator"
2325
id "org.springframework.boot.antora-contributor"
2426
id "org.springframework.boot.antora-dependencies"
2527
id "org.springframework.boot.deployed"
26-
id 'org.jetbrains.kotlin.jvm'
2728
}
2829

2930
description = "Spring Boot Docs"
3031

3132
configurations {
32-
autoConfiguration
33-
configurationProperties
3433
remoteSpringApplicationExample
3534
resolvedBom
3635
springApplicationExample
@@ -69,20 +68,6 @@ plugins.withType(EclipsePlugin) {
6968
}
7069

7170
dependencies {
72-
autoConfiguration(project(path: ":spring-boot-project:spring-boot-actuator-autoconfigure", configuration: "autoConfigurationMetadata"))
73-
autoConfiguration(project(path: ":spring-boot-project:spring-boot-autoconfigure", configuration: "autoConfigurationMetadata"))
74-
autoConfiguration(project(path: ":spring-boot-project:spring-boot-devtools", configuration: "autoConfigurationMetadata"))
75-
autoConfiguration(project(path: ":spring-boot-project:spring-boot-testcontainers", configuration: "autoConfigurationMetadata"))
76-
77-
configurationProperties(project(path: ":spring-boot-project:spring-boot", configuration: "configurationPropertiesMetadata"))
78-
configurationProperties(project(path: ":spring-boot-project:spring-boot-actuator", configuration: "configurationPropertiesMetadata"))
79-
configurationProperties(project(path: ":spring-boot-project:spring-boot-actuator-autoconfigure", configuration: "configurationPropertiesMetadata"))
80-
configurationProperties(project(path: ":spring-boot-project:spring-boot-autoconfigure", configuration: "configurationPropertiesMetadata"))
81-
configurationProperties(project(path: ":spring-boot-project:spring-boot-devtools", configuration: "configurationPropertiesMetadata"))
82-
configurationProperties(project(path: ":spring-boot-project:spring-boot-docker-compose", configuration: "configurationPropertiesMetadata"))
83-
configurationProperties(project(path: ":spring-boot-project:spring-boot-test-autoconfigure", configuration: "configurationPropertiesMetadata"))
84-
configurationProperties(project(path: ":spring-boot-project:spring-boot-testcontainers", configuration: "configurationPropertiesMetadata"))
85-
8671
dokkatoo(project(path: ":spring-boot-project:spring-boot"))
8772
dokkatoo(project(path: ":spring-boot-project:spring-boot-test"))
8873

@@ -255,8 +240,13 @@ tasks.register("documentStarters", org.springframework.boot.build.starters.Docum
255240
outputDir = layout.buildDirectory.dir("generated/docs/using/starters/")
256241
}
257242

243+
def autoConfigurationMetadataAggregate = aggregates.create("autoConfigurationMetadata") {
244+
category = Category.DOCUMENTATION
245+
usage = "auto-configuration-metadata"
246+
}
247+
258248
tasks.register("documentAutoConfigurationClasses", org.springframework.boot.build.autoconfigure.DocumentAutoConfigurationClasses) {
259-
autoConfiguration = configurations.autoConfiguration
249+
autoConfiguration = autoConfigurationMetadataAggregate.files
260250
outputDir = layout.buildDirectory.dir("generated/docs/auto-configuration-classes/documented-auto-configuration-classes/")
261251
}
262252

@@ -270,8 +260,13 @@ tasks.register("documentDependencyVersionProperties", org.springframework.boot.b
270260
resolvedBoms = configurations.resolvedBom
271261
}
272262

263+
def configurationPropertiesMetadataAggregate = aggregates.create("configurationPropertiesMetadata") {
264+
category = Category.DOCUMENTATION
265+
usage = "configuration-properties-metadata"
266+
}
267+
273268
tasks.register("documentConfigurationProperties", org.springframework.boot.build.context.properties.DocumentConfigurationProperties) {
274-
configurationPropertyMetadata = configurations.configurationProperties
269+
configurationPropertyMetadata = configurationPropertiesMetadataAggregate.files
275270
outputDir = layout.buildDirectory.dir("generated/docs/application-properties")
276271
}
277272

@@ -347,7 +342,7 @@ antoraContributions {
347342
from("src/main") {
348343
into "modules/ROOT/examples"
349344
}
350-
from(project.configurations.configurationProperties) {
345+
from(configurationPropertiesMetadataAggregate.files) {
351346
eachFile {
352347
it.path = rootProject
353348
.projectDir

0 commit comments

Comments
 (0)