diff --git a/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/documentation/HelpDocument.java b/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/documentation/HelpDocument.java index e0e01ddd..96f4c989 100644 --- a/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/documentation/HelpDocument.java +++ b/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/documentation/HelpDocument.java @@ -18,12 +18,14 @@ package io.spring.initializr.generator.spring.documentation; import java.io.IOException; import java.io.PrintWriter; +import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.Map; import io.spring.initializr.generator.io.template.MustacheTemplateRenderer; +import io.spring.initializr.generator.io.text.BulletedSection; import io.spring.initializr.generator.io.text.MustacheSection; import io.spring.initializr.generator.io.text.Section; @@ -38,6 +40,8 @@ public class HelpDocument { private final MustacheTemplateRenderer templateRenderer; + private final BulletedSection warnings; + private final GettingStartedSection gettingStarted; private final PreDefinedSection nextSteps; @@ -46,10 +50,20 @@ public class HelpDocument { public HelpDocument(MustacheTemplateRenderer templateRenderer) { this.templateRenderer = templateRenderer; + this.warnings = new BulletedSection<>(templateRenderer, "documentation/warnings"); this.gettingStarted = new GettingStartedSection(templateRenderer); this.nextSteps = new PreDefinedSection("Next Steps"); } + /** + * Return a section that can be used to inform the user that something happened when + * building this project. + * @return a warnings section rendered as bullet points + */ + public BulletedSection getWarnings() { + return this.warnings; + } + public GettingStartedSection gettingStarted() { return this.gettingStarted; } @@ -78,16 +92,19 @@ public class HelpDocument { } public void write(PrintWriter writer) throws IOException { - LinkedList
allSections = new LinkedList<>(this.sections); - allSections.addFirst(this.gettingStarted); - allSections.addLast(this.nextSteps); + List
allSections = new ArrayList<>(); + allSections.add(this.warnings); + allSections.add(this.gettingStarted); + allSections.addAll(this.sections); + allSections.add(this.nextSteps); for (Section section : allSections) { section.write(writer); } } public boolean isEmpty() { - return gettingStarted().isEmpty() && this.sections.isEmpty() && nextSteps().isEmpty(); + return getWarnings().isEmpty() && gettingStarted().isEmpty() && this.sections.isEmpty() + && nextSteps().isEmpty(); } } diff --git a/initializr-generator-spring/src/main/resources/templates/documentation/warnings.mustache b/initializr-generator-spring/src/main/resources/templates/documentation/warnings.mustache new file mode 100644 index 00000000..df1c8720 --- /dev/null +++ b/initializr-generator-spring/src/main/resources/templates/documentation/warnings.mustache @@ -0,0 +1,6 @@ +# Read Me First +The following was discovered as part of building this project: + +{{#items}} +* {{.}} +{{/items}} \ No newline at end of file diff --git a/initializr-generator-spring/src/test/java/io/spring/initializr/generator/spring/documentation/HelpDocumentTests.java b/initializr-generator-spring/src/test/java/io/spring/initializr/generator/spring/documentation/HelpDocumentTests.java index a548e204..1fc42f29 100644 --- a/initializr-generator-spring/src/test/java/io/spring/initializr/generator/spring/documentation/HelpDocumentTests.java +++ b/initializr-generator-spring/src/test/java/io/spring/initializr/generator/spring/documentation/HelpDocumentTests.java @@ -52,6 +52,16 @@ class HelpDocumentTests { assertThat(out).contains("# Test", ""); } + @Test + void renderWarnings() { + HelpDocument document = new HelpDocument(this.templateRenderer); + document.getWarnings().addItem("Invalid groupId '#invalid#'"); + document.getWarnings().addItem("Invalid package name '#invalid#'"); + String out = write(document); + assertThat(out).contains("# Read Me First", "The following was discovered as part of building this project:", + "", "* Invalid groupId '#invalid#'", "* Invalid package name '#invalid#'"); + } + @Test void renderLinks() { HelpDocument document = new HelpDocument(this.templateRenderer);