Skip to content

Commit 395ffb2

Browse files
committed
Merge branch '3.5.x'
Closes gh-46633
2 parents 7379ada + 2cdf434 commit 395ffb2

File tree

8 files changed

+164
-200
lines changed

8 files changed

+164
-200
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
@@ -22,6 +22,8 @@
2222
import org.gradle.api.Plugin;
2323
import org.gradle.api.Project;
2424
import org.gradle.api.artifacts.Configuration;
25+
import org.gradle.api.attributes.Category;
26+
import org.gradle.api.attributes.Usage;
2527
import org.gradle.api.file.RegularFile;
2628
import org.gradle.api.plugins.JavaPlugin;
2729
import org.gradle.api.plugins.JavaPluginExtension;
@@ -55,11 +57,7 @@
5557
*/
5658
public class ConfigurationPropertiesPlugin implements Plugin<Project> {
5759

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

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

0 commit comments

Comments
 (0)