This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-12644 in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-12644 by this push: new 1a6026a CAMEL-12644: Detect if spring boot configuration options has no description. 1a6026a is described below commit 1a6026af96e05d04dd15f5c9211b2442c9eab175 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Tue Jul 17 16:05:05 2018 +0200 CAMEL-12644: Detect if spring boot configuration options has no description. --- components/camel-spring-boot/pom.xml | 2 ++ platforms/spring-boot/components-starter/pom.xml | 2 ++ ...pdateSpringBootAutoConfigurationReadmeMojo.java | 28 ++++++++++++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/components/camel-spring-boot/pom.xml b/components/camel-spring-boot/pom.xml index bca471d..9892f38 100644 --- a/components/camel-spring-boot/pom.xml +++ b/components/camel-spring-boot/pom.xml @@ -141,6 +141,8 @@ <configuration> <!-- set to true to make build fail fast if missing documentation in docs files --> <failFast>false</failFast> + <!-- set to true to make build fail if an option has no description --> + <failOnMissingDescription>false</failOnMissingDescription> </configuration> <executions> <execution> diff --git a/platforms/spring-boot/components-starter/pom.xml b/platforms/spring-boot/components-starter/pom.xml index 0e65b06..d961b69 100644 --- a/platforms/spring-boot/components-starter/pom.xml +++ b/platforms/spring-boot/components-starter/pom.xml @@ -84,6 +84,8 @@ <configuration> <!-- set to true to make build fail fast if missing documentation in docs files --> <failFast>false</failFast> + <!-- set to true to make build fail if an option has no description --> + <failOnMissingDescription>false</failOnMissingDescription> </configuration> <executions> <execution> diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateSpringBootAutoConfigurationReadmeMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateSpringBootAutoConfigurationReadmeMojo.java index 3182ca5..4473509 100644 --- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateSpringBootAutoConfigurationReadmeMojo.java +++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateSpringBootAutoConfigurationReadmeMojo.java @@ -81,6 +81,13 @@ public class UpdateSpringBootAutoConfigurationReadmeMojo extends AbstractMojo { protected Boolean failFast; /** + * Whether to fail if an option has no documentation. + * + * @parameter + */ + protected Boolean failOnMissingDescription; + + /** * build context to check changed files and mark them for refresh (used for * m2e compatibility) * @@ -178,7 +185,20 @@ public class UpdateSpringBootAutoConfigurationReadmeMojo extends AbstractMojo { // spring-boot use lower cased keys String prefix = pos > 0 ? docName.substring(0, pos).toLowerCase(Locale.US) : null; - List models = parseSpringBootAutoConfigureModels(jsonFile, prefix); + List<SpringBootAutoConfigureOptionModel> models = parseSpringBootAutoConfigureModels(jsonFile, prefix); + + // check for missing description on options + boolean noDescription = false; + for (SpringBootAutoConfigureOptionModel o : models) { + if (StringHelper.isEmpty(o.getDescription())) { + noDescription = true; + getLog().warn("Option " + o.getName() + " has no description"); + } + } + if (noDescription && isFailOnNoDescription()) { + throw new MojoExecutionException("Failed build due failOnMissingDescription=true"); + } + String options = templateAutoConfigurationOptions(models); boolean updated = updateAutoConfigureOptions(docFile, options); if (updated) { @@ -267,7 +287,7 @@ public class UpdateSpringBootAutoConfigurationReadmeMojo extends AbstractMojo { return true; } - private List parseSpringBootAutoConfigureModels(File file, String include) throws IOException, DeserializationException { + private List<SpringBootAutoConfigureOptionModel> parseSpringBootAutoConfigureModels(File file, String include) throws IOException, DeserializationException { getLog().debug("Parsing Spring Boot AutoConfigureModel using include: " + include); List<SpringBootAutoConfigureOptionModel> answer = new ArrayList<>(); @@ -349,4 +369,8 @@ public class UpdateSpringBootAutoConfigurationReadmeMojo extends AbstractMojo { return failFast != null && failFast; } + private boolean isFailOnNoDescription() { + return failOnMissingDescription != null && failOnMissingDescription; + } + }