diff --git a/spring-modulith-docs/src/main/java/org/springframework/modulith/docs/Documenter.java b/spring-modulith-docs/src/main/java/org/springframework/modulith/docs/Documenter.java index 7a3affaf1..b91f6a5e6 100644 --- a/spring-modulith-docs/src/main/java/org/springframework/modulith/docs/Documenter.java +++ b/spring-modulith-docs/src/main/java/org/springframework/modulith/docs/Documenter.java @@ -533,8 +533,13 @@ private ComponentView createComponentView(DiagramOptions options, @Nullable Appl private void clearOutputFolder() { - try(Stream paths = Files.walk(Paths.get(options.outputFolder)).sorted(Comparator.reverseOrder())) { - paths.map(Path::toFile).forEach(File::delete); + Path outputPath = Paths.get(options.outputFolder); + if (!outputPath.toFile().exists()) { + return; + } + + try (Stream paths = Files.walk(outputPath)) { + paths.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); } catch (IOException o_O) { throw new RuntimeException(o_O); }