diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java index 1194b4082d1..1b79a33f341 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java @@ -142,6 +142,7 @@ class TypeUtils { String javadoc = (element != null ? this.env.getElementUtils().getDocComment(element) : null); if (javadoc != null) { + javadoc = javadoc.replaceAll("\\n", ""); javadoc = javadoc.trim(); } return ("".equals(javadoc) ? null : javadoc); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java index 298de012af4..239ddbc2c69 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java @@ -64,6 +64,7 @@ import org.springframework.boot.configurationsample.method.MethodAndClassConfig; import org.springframework.boot.configurationsample.method.SimpleMethodConfig; import org.springframework.boot.configurationsample.simple.ClassWithNestedProperties; import org.springframework.boot.configurationsample.simple.DeprecatedSingleProperty; +import org.springframework.boot.configurationsample.simple.DescriptionProperties; import org.springframework.boot.configurationsample.simple.HierarchicalProperties; import org.springframework.boot.configurationsample.simple.NotAnnotated; import org.springframework.boot.configurationsample.simple.SimpleArrayProperties; @@ -210,6 +211,20 @@ public class ConfigurationMetadataAnnotationProcessorTests { .fromSource(HierarchicalProperties.class)); } + @Test + public void descriptionProperties() { + ConfigurationMetadata metadata = compile(DescriptionProperties.class); + assertThat(metadata).has(Metadata.withGroup("description") + .fromSource(DescriptionProperties.class)); + assertThat(metadata).has(Metadata.withProperty("description.simple", String.class) + .fromSource(DescriptionProperties.class) + .withDescription("A simple description.")); + assertThat(metadata).has(Metadata + .withProperty("description.multi-line", String.class) + .fromSource(DescriptionProperties.class).withDescription( + "This is a lengthy description that spans across multiple lines to showcase that the carriage return is cleaned automatically.")); + } + @Test @SuppressWarnings("deprecation") public void deprecatedProperties() { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/fieldvalues/FieldValues.class b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/fieldvalues/FieldValues.class deleted file mode 100644 index 4b15ca5a34e..00000000000 Binary files a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/fieldvalues/FieldValues.class and /dev/null differ diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/simple/DescriptionProperties.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/simple/DescriptionProperties.java new file mode 100644 index 00000000000..7077b4070df --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/simple/DescriptionProperties.java @@ -0,0 +1,56 @@ +/* + * Copyright 2012-2018 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 + * + * http://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.configurationsample.simple; + +import org.springframework.boot.configurationsample.ConfigurationProperties; + +/** + * Configuration properties with various description styles. + * + * @author Stephane Nicoll + */ +@ConfigurationProperties("description") +public class DescriptionProperties { + + /** + * A simple description. + */ + private String simple; + + /** + * This is a lengthy description that spans across multiple lines to showcase that the + * carriage return is cleaned automatically. + */ + private String multiLine; + + public String getSimple() { + return this.simple; + } + + public void setSimple(String simple) { + this.simple = simple; + } + + public String getMultiLine() { + return this.multiLine; + } + + public void setMultiLine(String multiLine) { + this.multiLine = multiLine; + } + +}