Don't generate @Configuration metadata

Update `AutoConfigureAnnotationProcessor` to no longer store
`@Configuration.value` in the meta-data JSON since we never actually
read it.

Closes gh-16608
pull/18501/head
Phillip Webb 5 years ago
parent 795303d667
commit 61873fbf42

@ -51,8 +51,7 @@ import javax.tools.StandardLocation;
* @author Phillip Webb
* @since 1.5.0
*/
@SupportedAnnotationTypes({ "org.springframework.context.annotation.Configuration",
"org.springframework.boot.autoconfigure.condition.ConditionalOnClass",
@SupportedAnnotationTypes({ "org.springframework.boot.autoconfigure.condition.ConditionalOnClass",
"org.springframework.boot.autoconfigure.condition.ConditionalOnBean",
"org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate",
"org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication",
@ -79,7 +78,6 @@ public class AutoConfigureAnnotationProcessor extends AbstractProcessor {
}
protected void addAnnotations(Map<String, String> annotations) {
annotations.put("Configuration", "org.springframework.context.annotation.Configuration");
annotations.put("ConditionalOnClass", "org.springframework.boot.autoconfigure.condition.ConditionalOnClass");
annotations.put("ConditionalOnBean", "org.springframework.boot.autoconfigure.condition.ConditionalOnBean");
annotations.put("ConditionalOnSingleCandidate",
@ -92,7 +90,6 @@ public class AutoConfigureAnnotationProcessor extends AbstractProcessor {
}
private void addValueExtractors(Map<String, ValueExtractor> attributes) {
attributes.put("Configuration", ValueExtractor.allFrom("value"));
attributes.put("ConditionalOnClass", new OnClassConditionValueExtractor());
attributes.put("ConditionalOnBean", new OnBeanConditionValueExtractor());
attributes.put("ConditionalOnSingleCandidate", new OnBeanConditionValueExtractor());

@ -18,8 +18,6 @@ package org.springframework.boot.autoconfigureprocessor;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.junit.jupiter.api.BeforeEach;
@ -50,14 +48,12 @@ class AutoConfigureAnnotationProcessorTests {
@Test
void annotatedClass() throws Exception {
Properties properties = compile(TestClassConfiguration.class);
assertThat(properties).hasSize(6);
assertThat(properties).hasSize(5);
assertThat(properties).containsEntry(
"org.springframework.boot.autoconfigureprocessor.TestClassConfiguration.ConditionalOnClass",
"java.io.InputStream,org.springframework.boot.autoconfigureprocessor."
+ "TestClassConfiguration$Nested,org.springframework.foo");
assertThat(properties).containsKey("org.springframework.boot.autoconfigureprocessor.TestClassConfiguration");
assertThat(properties)
.containsKey("org.springframework.boot.autoconfigureprocessor.TestClassConfiguration.Configuration");
assertThat(properties)
.doesNotContainKey("org.springframework.boot.autoconfigureprocessor.TestClassConfiguration$Nested");
assertThat(properties).containsEntry(
@ -72,7 +68,7 @@ class AutoConfigureAnnotationProcessorTests {
@Test
void annotatedClassWithOnBeanThatHasName() throws Exception {
Properties properties = compile(TestOnBeanWithNameClassConfiguration.class);
assertThat(properties).hasSize(3);
assertThat(properties).hasSize(2);
assertThat(properties).containsEntry(
"org.springframework.boot.autoconfigureprocessor.TestOnBeanWithNameClassConfiguration.ConditionalOnBean",
"");
@ -81,15 +77,7 @@ class AutoConfigureAnnotationProcessorTests {
@Test
void annotatedMethod() throws Exception {
Properties properties = compile(TestMethodConfiguration.class);
List<String> matching = new ArrayList<>();
for (Object key : properties.keySet()) {
if (key.toString().startsWith("org.springframework.boot.autoconfigureprocessor.TestMethodConfiguration")) {
matching.add(key.toString());
}
}
assertThat(matching).hasSize(2)
.contains("org.springframework.boot.autoconfigureprocessor.TestMethodConfiguration")
.contains("org.springframework.boot.autoconfigureprocessor.TestMethodConfiguration.Configuration");
assertThat(properties).isNull();
}
@Test

@ -29,11 +29,10 @@ import javax.annotation.processing.SupportedAnnotationTypes;
*
* @author Madhura Bhave
*/
@SupportedAnnotationTypes({ "org.springframework.boot.autoconfigureprocessor.TestConfiguration",
"org.springframework.boot.autoconfigureprocessor.TestConditionalOnClass",
"org.springframework.boot.autoconfigure.condition.TestConditionalOnBean",
"org.springframework.boot.autoconfigure.condition.TestConditionalOnSingleCandidate",
"org.springframework.boot.autoconfigure.condition.TestConditionalOnWebApplication",
@SupportedAnnotationTypes({ "org.springframework.boot.autoconfigureprocessor.TestConditionalOnClass",
"org.springframework.boot.autoconfigureprocessor.TestConditionalOnBean",
"org.springframework.boot.autoconfigureprocessor.TestConditionalOnSingleCandidate",
"org.springframework.boot.autoconfigureprocessor.TestConditionalOnWebApplication",
"org.springframework.boot.autoconfigureprocessor.TestAutoConfigureBefore",
"org.springframework.boot.autoconfigureprocessor.TestAutoConfigureAfter",
"org.springframework.boot.autoconfigureprocessor.TestAutoConfigureOrder" })
@ -47,7 +46,6 @@ public class TestAutoConfigureAnnotationProcessor extends AutoConfigureAnnotatio
@Override
protected void addAnnotations(Map<String, String> annotations) {
put(annotations, "Configuration", TestConfiguration.class);
put(annotations, "ConditionalOnClass", TestConditionalOnClass.class);
put(annotations, "ConditionalOnBean", TestConditionalOnBean.class);
put(annotations, "ConditionalOnSingleCandidate", TestConditionalOnSingleCandidate.class);

@ -23,7 +23,6 @@ import org.springframework.boot.autoconfigureprocessor.TestConditionalOnWebAppli
*
* @author Madhura Bhave
*/
@TestConfiguration
@TestConditionalOnClass(name = { "org.springframework.foo", "java.io.InputStream" },
value = TestClassConfiguration.Nested.class)
@TestConditionalOnBean(type = "java.io.OutputStream")

@ -1,38 +0,0 @@
/*
* Copyright 2012-2019 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.autoconfigureprocessor;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Alternative to Spring's {@code @Configuration} for testing (removes the need for a
* dependency on the real annotation).
*
* @author Phillip Webb
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface TestConfiguration {
String value() default "";
}

@ -23,7 +23,6 @@ import java.io.OutputStream;
*
* @author Madhura Bhave
*/
@TestConfiguration
public class TestMethodConfiguration {
@TestConditionalOnClass(name = "java.io.InputStream", value = OutputStream.class)

@ -21,7 +21,6 @@ package org.springframework.boot.autoconfigureprocessor;
*
* @author Phillip Webb
*/
@TestConfiguration
@TestConditionalOnBean(name = "test", type = "java.io.OutputStream")
public class TestOnBeanWithNameClassConfiguration {

Loading…
Cancel
Save