Merge branch '2.7.x' into 3.0.x

This commit is contained in:
Phillip Webb
2023-02-21 23:15:40 -08:00
1890 changed files with 27173 additions and 21952 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -84,25 +84,25 @@ public class AutoConfigureAnnotationProcessor extends AbstractProcessor {
private void addConditionPropertyGenerators(List<PropertyGenerator> generators) {
String annotationPackage = "org.springframework.boot.autoconfigure.condition";
generators.add(PropertyGenerator.of(annotationPackage, "ConditionalOnClass")
.withAnnotation(new OnClassConditionValueExtractor()));
.withAnnotation(new OnClassConditionValueExtractor()));
generators.add(PropertyGenerator.of(annotationPackage, "ConditionalOnBean")
.withAnnotation(new OnBeanConditionValueExtractor()));
.withAnnotation(new OnBeanConditionValueExtractor()));
generators.add(PropertyGenerator.of(annotationPackage, "ConditionalOnSingleCandidate")
.withAnnotation(new OnBeanConditionValueExtractor()));
.withAnnotation(new OnBeanConditionValueExtractor()));
generators.add(PropertyGenerator.of(annotationPackage, "ConditionalOnWebApplication")
.withAnnotation(ValueExtractor.allFrom("type")));
.withAnnotation(ValueExtractor.allFrom("type")));
}
private void addAutoConfigurePropertyGenerators(List<PropertyGenerator> generators) {
String annotationPackage = "org.springframework.boot.autoconfigure";
generators.add(PropertyGenerator.of(annotationPackage, "AutoConfigureBefore", true)
.withAnnotation(ValueExtractor.allFrom("value", "name"))
.withAnnotation("AutoConfiguration", ValueExtractor.allFrom("before", "beforeName")));
.withAnnotation(ValueExtractor.allFrom("value", "name"))
.withAnnotation("AutoConfiguration", ValueExtractor.allFrom("before", "beforeName")));
generators.add(PropertyGenerator.of(annotationPackage, "AutoConfigureAfter", true)
.withAnnotation(ValueExtractor.allFrom("value", "name"))
.withAnnotation("AutoConfiguration", ValueExtractor.allFrom("after", "afterName")));
.withAnnotation(ValueExtractor.allFrom("value", "name"))
.withAnnotation("AutoConfiguration", ValueExtractor.allFrom("after", "afterName")));
generators.add(PropertyGenerator.of(annotationPackage, "AutoConfigureOrder")
.withAnnotation(ValueExtractor.allFrom("value")));
.withAnnotation(ValueExtractor.allFrom("value")));
}
@Override
@@ -207,7 +207,7 @@ public class AutoConfigureAnnotationProcessor extends AbstractProcessor {
Object value = annotationValue.getValue();
if (value instanceof List) {
return ((List<AnnotationValue>) value).stream()
.map((annotation) -> extractValue(annotation.getValue()));
.map((annotation) -> extractValue(annotation.getValue()));
}
return Stream.of(extractValue(value));
}
@@ -248,7 +248,7 @@ public class AutoConfigureAnnotationProcessor extends AbstractProcessor {
public List<Object> getValues(AnnotationMirror annotation) {
Map<String, AnnotationValue> attributes = new LinkedHashMap<>();
annotation.getElementValues()
.forEach((key, value) -> attributes.put(key.getSimpleName().toString(), value));
.forEach((key, value) -> attributes.put(key.getSimpleName().toString(), value));
if (attributes.containsKey("name")) {
return Collections.emptyList();
}
@@ -274,8 +274,9 @@ public class AutoConfigureAnnotationProcessor extends AbstractProcessor {
}
private int compare(Object o1, Object o2) {
return Comparator.comparing(this::isSpringClass).thenComparing(String.CASE_INSENSITIVE_ORDER)
.compare(o1.toString(), o2.toString());
return Comparator.comparing(this::isSpringClass)
.thenComparing(String.CASE_INSENSITIVE_ORDER)
.compare(o1.toString(), o2.toString());
}
private boolean isSpringClass(String type) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -47,9 +47,9 @@ class AutoConfigureAnnotationProcessorTests {
"java.io.InputStream,org.springframework.boot.autoconfigureprocessor."
+ "TestClassConfiguration$Nested,org.springframework.foo");
assertThat(properties)
.containsKey("org.springframework.boot.autoconfigureprocessor.TestClassConfiguration");
.containsKey("org.springframework.boot.autoconfigureprocessor.TestClassConfiguration");
assertThat(properties)
.containsKey("org.springframework.boot.autoconfigureprocessor.TestClassConfiguration$Nested");
.containsKey("org.springframework.boot.autoconfigureprocessor.TestClassConfiguration$Nested");
assertThat(properties).containsEntry(
"org.springframework.boot.autoconfigureprocessor.TestClassConfiguration.ConditionalOnBean",
"java.io.OutputStream");
@@ -156,7 +156,7 @@ class AutoConfigureAnnotationProcessorTests {
TestCompiler compiler = TestCompiler.forSystem().withProcessors(processor).withSources(sourceFile);
compiler.compile((compiled) -> {
InputStream propertiesFile = compiled.getClassLoader()
.getResourceAsStream(AutoConfigureAnnotationProcessor.PROPERTIES_PATH);
.getResourceAsStream(AutoConfigureAnnotationProcessor.PROPERTIES_PATH);
consumer.accept(propertiesFile);
});
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -45,21 +45,21 @@ public class TestAutoConfigureAnnotationProcessor extends AutoConfigureAnnotatio
List<PropertyGenerator> generators = new ArrayList<>();
String annotationPackage = "org.springframework.boot.autoconfigureprocessor";
generators.add(PropertyGenerator.of(annotationPackage, "ConditionalOnClass")
.withAnnotation("TestConditionalOnClass", new OnClassConditionValueExtractor()));
.withAnnotation("TestConditionalOnClass", new OnClassConditionValueExtractor()));
generators.add(PropertyGenerator.of(annotationPackage, "ConditionalOnBean")
.withAnnotation("TestConditionalOnBean", new OnBeanConditionValueExtractor()));
.withAnnotation("TestConditionalOnBean", new OnBeanConditionValueExtractor()));
generators.add(PropertyGenerator.of(annotationPackage, "ConditionalOnSingleCandidate")
.withAnnotation("TestConditionalOnSingleCandidate", new OnBeanConditionValueExtractor()));
.withAnnotation("TestConditionalOnSingleCandidate", new OnBeanConditionValueExtractor()));
generators.add(PropertyGenerator.of(annotationPackage, "ConditionalOnWebApplication")
.withAnnotation("TestConditionalOnWebApplication", ValueExtractor.allFrom("type")));
.withAnnotation("TestConditionalOnWebApplication", ValueExtractor.allFrom("type")));
generators.add(PropertyGenerator.of(annotationPackage, "AutoConfigureBefore", true)
.withAnnotation("TestAutoConfigureBefore", ValueExtractor.allFrom("value", "name"))
.withAnnotation("TestAutoConfiguration", ValueExtractor.allFrom("before", "beforeName")));
.withAnnotation("TestAutoConfigureBefore", ValueExtractor.allFrom("value", "name"))
.withAnnotation("TestAutoConfiguration", ValueExtractor.allFrom("before", "beforeName")));
generators.add(PropertyGenerator.of(annotationPackage, "AutoConfigureAfter", true)
.withAnnotation("TestAutoConfigureAfter", ValueExtractor.allFrom("value", "name"))
.withAnnotation("TestAutoConfiguration", ValueExtractor.allFrom("after", "afterName")));
.withAnnotation("TestAutoConfigureAfter", ValueExtractor.allFrom("value", "name"))
.withAnnotation("TestAutoConfiguration", ValueExtractor.allFrom("after", "afterName")));
generators.add(PropertyGenerator.of(annotationPackage, "AutoConfigureOrder")
.withAnnotation("TestAutoConfigureOrder", ValueExtractor.allFrom("value")));
.withAnnotation("TestAutoConfigureOrder", ValueExtractor.allFrom("value")));
return generators;
}