From e2d1f42e71fc98c45777e313d8ec9a10983bcca8 Mon Sep 17 00:00:00 2001 From: Jarle Hansen Date: Wed, 25 Sep 2024 08:33:11 +0200 Subject: [PATCH 1/2] Add beans for Java, Kotlin and Groovy SourceCodeWriters See gh-1571 --- .../GroovyProjectGenerationConfiguration.java | 21 ++++++++++++------- .../JavaProjectGenerationConfiguration.java | 21 ++++++++++++------- .../KotlinProjectGenerationConfiguration.java | 17 +++++++++------ 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/groovy/GroovyProjectGenerationConfiguration.java b/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/groovy/GroovyProjectGenerationConfiguration.java index af9841a9bb..e0a6c79e65 100644 --- a/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/groovy/GroovyProjectGenerationConfiguration.java +++ b/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/groovy/GroovyProjectGenerationConfiguration.java @@ -58,23 +58,28 @@ public GroovyProjectGenerationConfiguration(ProjectDescription description, this.indentingWriterFactory = indentingWriterFactory; } + @Bean + public GroovySourceCodeWriter groovySourceCodeWriter() { + return new GroovySourceCodeWriter(this.indentingWriterFactory); + } + @Bean public MainSourceCodeProjectContributor mainGroovySourceCodeProjectContributor( ObjectProvider> mainApplicationTypeCustomizers, ObjectProvider> mainCompilationUnitCustomizers, - ObjectProvider> mainSourceCodeCustomizers) { - return new MainSourceCodeProjectContributor<>(this.description, GroovySourceCode::new, - new GroovySourceCodeWriter(this.indentingWriterFactory), mainApplicationTypeCustomizers, - mainCompilationUnitCustomizers, mainSourceCodeCustomizers); + ObjectProvider> mainSourceCodeCustomizers, + GroovySourceCodeWriter groovySourceCodeWriter) { + return new MainSourceCodeProjectContributor<>(this.description, GroovySourceCode::new, groovySourceCodeWriter, + mainApplicationTypeCustomizers, mainCompilationUnitCustomizers, mainSourceCodeCustomizers); } @Bean public TestSourceCodeProjectContributor testGroovySourceCodeProjectContributor( ObjectProvider> testApplicationTypeCustomizers, - ObjectProvider> testSourceCodeCustomizers) { - return new TestSourceCodeProjectContributor<>(this.description, GroovySourceCode::new, - new GroovySourceCodeWriter(this.indentingWriterFactory), testApplicationTypeCustomizers, - testSourceCodeCustomizers); + ObjectProvider> testSourceCodeCustomizers, + GroovySourceCodeWriter groovySourceCodeWriter) { + return new TestSourceCodeProjectContributor<>(this.description, GroovySourceCode::new, groovySourceCodeWriter, + testApplicationTypeCustomizers, testSourceCodeCustomizers); } } diff --git a/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/java/JavaProjectGenerationConfiguration.java b/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/java/JavaProjectGenerationConfiguration.java index 65e6c973d2..63b3562c12 100644 --- a/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/java/JavaProjectGenerationConfiguration.java +++ b/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/java/JavaProjectGenerationConfiguration.java @@ -58,23 +58,28 @@ public JavaProjectGenerationConfiguration(ProjectDescription description, this.indentingWriterFactory = indentingWriterFactory; } + @Bean + public JavaSourceCodeWriter javaSourceCodeWriter() { + return new JavaSourceCodeWriter(this.indentingWriterFactory); + } + @Bean public MainSourceCodeProjectContributor mainJavaSourceCodeProjectContributor( ObjectProvider> mainApplicationTypeCustomizers, ObjectProvider> mainCompilationUnitCustomizers, - ObjectProvider> mainSourceCodeCustomizers) { - return new MainSourceCodeProjectContributor<>(this.description, JavaSourceCode::new, - new JavaSourceCodeWriter(this.indentingWriterFactory), mainApplicationTypeCustomizers, - mainCompilationUnitCustomizers, mainSourceCodeCustomizers); + ObjectProvider> mainSourceCodeCustomizers, + JavaSourceCodeWriter javaSourceCodeWriter) { + return new MainSourceCodeProjectContributor<>(this.description, JavaSourceCode::new, javaSourceCodeWriter, + mainApplicationTypeCustomizers, mainCompilationUnitCustomizers, mainSourceCodeCustomizers); } @Bean public TestSourceCodeProjectContributor testJavaSourceCodeProjectContributor( ObjectProvider> testApplicationTypeCustomizers, - ObjectProvider> testSourceCodeCustomizers) { - return new TestSourceCodeProjectContributor<>(this.description, JavaSourceCode::new, - new JavaSourceCodeWriter(this.indentingWriterFactory), testApplicationTypeCustomizers, - testSourceCodeCustomizers); + ObjectProvider> testSourceCodeCustomizers, + JavaSourceCodeWriter javaSourceCodeWriter) { + return new TestSourceCodeProjectContributor<>(this.description, JavaSourceCode::new, javaSourceCodeWriter, + testApplicationTypeCustomizers, testSourceCodeCustomizers); } } diff --git a/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/kotlin/KotlinProjectGenerationConfiguration.java b/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/kotlin/KotlinProjectGenerationConfiguration.java index fe9f19c804..ca10847a31 100644 --- a/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/kotlin/KotlinProjectGenerationConfiguration.java +++ b/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/kotlin/KotlinProjectGenerationConfiguration.java @@ -65,22 +65,27 @@ public KotlinProjectGenerationConfiguration(ProjectDescription description, this.indentingWriterFactory = indentingWriterFactory; } + @Bean + public KotlinSourceCodeWriter kotlinSourceCodeWriter() { + return new KotlinSourceCodeWriter(this.description.getLanguage(), this.indentingWriterFactory); + } + @Bean public MainSourceCodeProjectContributor mainKotlinSourceCodeProjectContributor( ObjectProvider> mainApplicationTypeCustomizers, ObjectProvider> mainCompilationUnitCustomizers, - ObjectProvider> mainSourceCodeCustomizers) { - return new MainSourceCodeProjectContributor<>(this.description, KotlinSourceCode::new, - new KotlinSourceCodeWriter(this.description.getLanguage(), this.indentingWriterFactory), + ObjectProvider> mainSourceCodeCustomizers, + KotlinSourceCodeWriter kotlinSourceCodeWriter) { + return new MainSourceCodeProjectContributor<>(this.description, KotlinSourceCode::new, kotlinSourceCodeWriter, mainApplicationTypeCustomizers, mainCompilationUnitCustomizers, mainSourceCodeCustomizers); } @Bean public TestSourceCodeProjectContributor testKotlinSourceCodeProjectContributor( ObjectProvider> testApplicationTypeCustomizers, - ObjectProvider> testSourceCodeCustomizers) { - return new TestSourceCodeProjectContributor<>(this.description, KotlinSourceCode::new, - new KotlinSourceCodeWriter(this.description.getLanguage(), this.indentingWriterFactory), + ObjectProvider> testSourceCodeCustomizers, + KotlinSourceCodeWriter kotlinSourceCodeWriter) { + return new TestSourceCodeProjectContributor<>(this.description, KotlinSourceCode::new, kotlinSourceCodeWriter, testApplicationTypeCustomizers, testSourceCodeCustomizers); } From 80f374f65a7b9eef051c2cbcae071399ef3ce022 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Wed, 25 Sep 2024 13:21:35 +0200 Subject: [PATCH 2/2] Polish "Add beans for Java, Kotlin and Groovy SourceCodeWriters" See gh-1571 --- .../GroovyProjectGenerationConfiguration.java | 14 +++++--------- .../java/JavaProjectGenerationConfiguration.java | 14 +++++--------- .../KotlinProjectGenerationConfiguration.java | 14 +++++--------- 3 files changed, 15 insertions(+), 27 deletions(-) diff --git a/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/groovy/GroovyProjectGenerationConfiguration.java b/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/groovy/GroovyProjectGenerationConfiguration.java index e0a6c79e65..c366224c64 100644 --- a/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/groovy/GroovyProjectGenerationConfiguration.java +++ b/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/groovy/GroovyProjectGenerationConfiguration.java @@ -50,21 +50,17 @@ public class GroovyProjectGenerationConfiguration { private final ProjectDescription description; - private final IndentingWriterFactory indentingWriterFactory; - - public GroovyProjectGenerationConfiguration(ProjectDescription description, - IndentingWriterFactory indentingWriterFactory) { + public GroovyProjectGenerationConfiguration(ProjectDescription description) { this.description = description; - this.indentingWriterFactory = indentingWriterFactory; } @Bean - public GroovySourceCodeWriter groovySourceCodeWriter() { - return new GroovySourceCodeWriter(this.indentingWriterFactory); + GroovySourceCodeWriter groovySourceCodeWriter(IndentingWriterFactory indentingWriterFactory) { + return new GroovySourceCodeWriter(indentingWriterFactory); } @Bean - public MainSourceCodeProjectContributor mainGroovySourceCodeProjectContributor( + MainSourceCodeProjectContributor mainGroovySourceCodeProjectContributor( ObjectProvider> mainApplicationTypeCustomizers, ObjectProvider> mainCompilationUnitCustomizers, ObjectProvider> mainSourceCodeCustomizers, @@ -74,7 +70,7 @@ public MainSourceCodeProjectContributor testGroovySourceCodeProjectContributor( + TestSourceCodeProjectContributor testGroovySourceCodeProjectContributor( ObjectProvider> testApplicationTypeCustomizers, ObjectProvider> testSourceCodeCustomizers, GroovySourceCodeWriter groovySourceCodeWriter) { diff --git a/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/java/JavaProjectGenerationConfiguration.java b/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/java/JavaProjectGenerationConfiguration.java index 63b3562c12..abaf3b1624 100644 --- a/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/java/JavaProjectGenerationConfiguration.java +++ b/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/java/JavaProjectGenerationConfiguration.java @@ -50,21 +50,17 @@ public class JavaProjectGenerationConfiguration { private final ProjectDescription description; - private final IndentingWriterFactory indentingWriterFactory; - - public JavaProjectGenerationConfiguration(ProjectDescription description, - IndentingWriterFactory indentingWriterFactory) { + public JavaProjectGenerationConfiguration(ProjectDescription description) { this.description = description; - this.indentingWriterFactory = indentingWriterFactory; } @Bean - public JavaSourceCodeWriter javaSourceCodeWriter() { - return new JavaSourceCodeWriter(this.indentingWriterFactory); + JavaSourceCodeWriter javaSourceCodeWriter(IndentingWriterFactory indentingWriterFactory) { + return new JavaSourceCodeWriter(indentingWriterFactory); } @Bean - public MainSourceCodeProjectContributor mainJavaSourceCodeProjectContributor( + MainSourceCodeProjectContributor mainJavaSourceCodeProjectContributor( ObjectProvider> mainApplicationTypeCustomizers, ObjectProvider> mainCompilationUnitCustomizers, ObjectProvider> mainSourceCodeCustomizers, @@ -74,7 +70,7 @@ public MainSourceCodeProjectContributor testJavaSourceCodeProjectContributor( + TestSourceCodeProjectContributor testJavaSourceCodeProjectContributor( ObjectProvider> testApplicationTypeCustomizers, ObjectProvider> testSourceCodeCustomizers, JavaSourceCodeWriter javaSourceCodeWriter) { diff --git a/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/kotlin/KotlinProjectGenerationConfiguration.java b/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/kotlin/KotlinProjectGenerationConfiguration.java index ca10847a31..a19ac639b0 100644 --- a/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/kotlin/KotlinProjectGenerationConfiguration.java +++ b/initializr-generator-spring/src/main/java/io/spring/initializr/generator/spring/code/kotlin/KotlinProjectGenerationConfiguration.java @@ -57,21 +57,17 @@ public class KotlinProjectGenerationConfiguration { private final ProjectDescription description; - private final IndentingWriterFactory indentingWriterFactory; - - public KotlinProjectGenerationConfiguration(ProjectDescription description, - IndentingWriterFactory indentingWriterFactory) { + public KotlinProjectGenerationConfiguration(ProjectDescription description) { this.description = description; - this.indentingWriterFactory = indentingWriterFactory; } @Bean - public KotlinSourceCodeWriter kotlinSourceCodeWriter() { - return new KotlinSourceCodeWriter(this.description.getLanguage(), this.indentingWriterFactory); + KotlinSourceCodeWriter kotlinSourceCodeWriter(IndentingWriterFactory indentingWriterFactory) { + return new KotlinSourceCodeWriter(this.description.getLanguage(), indentingWriterFactory); } @Bean - public MainSourceCodeProjectContributor mainKotlinSourceCodeProjectContributor( + MainSourceCodeProjectContributor mainKotlinSourceCodeProjectContributor( ObjectProvider> mainApplicationTypeCustomizers, ObjectProvider> mainCompilationUnitCustomizers, ObjectProvider> mainSourceCodeCustomizers, @@ -81,7 +77,7 @@ public MainSourceCodeProjectContributor testKotlinSourceCodeProjectContributor( + TestSourceCodeProjectContributor testKotlinSourceCodeProjectContributor( ObjectProvider> testApplicationTypeCustomizers, ObjectProvider> testSourceCodeCustomizers, KotlinSourceCodeWriter kotlinSourceCodeWriter) {