diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersProjectGenerationConfiguration.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersProjectGenerationConfiguration.java index 2ec09f0a02f..4362a230bc6 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersProjectGenerationConfiguration.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersProjectGenerationConfiguration.java @@ -38,7 +38,6 @@ import org.springframework.beans.factory.ObjectProvider; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; /** * Configuration for generation of projects that depend on Testcontainers. @@ -69,7 +68,7 @@ public ImplicitDependencyHelpDocumentCustomizer testcontainersHelpCustomizer(Bui @Configuration(proxyBeanMethods = false) @ConditionalOnPlatformVersion("3.1.0-RC1") - static class ServiceConnectionsConfiguration { + static class SpringBoot31Configuration { @Bean ServiceConnections serviceConnections(ObjectProvider customizers) { @@ -78,67 +77,64 @@ ServiceConnections serviceConnections(ObjectProvider springBootTestcontainersBuildCustomizer() { + return (build) -> build.dependencies() + .add("spring-boot-testcontainers", + Dependency.withCoordinates("org.springframework.boot", "spring-boot-testcontainers") + .scope(DependencyScope.TEST_COMPILE)); - @Bean - BuildCustomizer springBootTestcontainersBuildCustomizer() { - return (build) -> build.dependencies() - .add("spring-boot-testcontainers", - Dependency.withCoordinates("org.springframework.boot", "spring-boot-testcontainers") - .scope(DependencyScope.TEST_COMPILE)); + } - } + @Bean + TestContainersHelpDocumentCustomizer springBootTestcontainersHelpDocumentCustomizer( + ProjectDescription description, ServiceConnections serviceConnections) { + return new TestContainersHelpDocumentCustomizer(description, serviceConnections); + } - @Bean - TestContainersHelpDocumentCustomizer springBootTestcontainersHelpDocumentCustomizer( - ProjectDescription description, ServiceConnections serviceConnections) { - return new TestContainersHelpDocumentCustomizer(description, serviceConnections); } - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnPlatformVersion("3.1.0-RC1") - @Import(ServiceConnectionsConfiguration.class) - static class TestApplicationConfiguration { - - private final ProjectDescription description; + @Configuration(proxyBeanMethods = false) + static class TestApplicationConfiguration { + + private final ProjectDescription description; + + private final IndentingWriterFactory indentingWriterFactory; + + TestApplicationConfiguration(ProjectDescription description, + IndentingWriterFactory indentingWriterFactory) { + this.description = description; + this.indentingWriterFactory = indentingWriterFactory; + } + + @Bean + @ConditionalOnLanguage(GroovyLanguage.ID) + GroovyTestContainersApplicationCodeProjectContributor groovyTestContainersApplicationCodeProjectContributor( + ServiceConnections serviceConnections) { + return new GroovyTestContainersApplicationCodeProjectContributor(this.indentingWriterFactory, + this.description, serviceConnections); + } + + @Bean + @ConditionalOnLanguage(KotlinLanguage.ID) + @ConditionalOnPlatformVersion("3.1.1-SNAPSHOT") // https://github.com/spring-projects/spring-boot/issues/35756 + KotlinTestContainersApplicationCodeProjectContributor kotlinTestContainersApplicationCodeProjectContributor( + ServiceConnections serviceConnections) { + return new KotlinTestContainersApplicationCodeProjectContributor(this.indentingWriterFactory, + this.description, serviceConnections); + } + + @Bean + @ConditionalOnLanguage(JavaLanguage.ID) + JavaTestContainersApplicationCodeProjectContributor javaTestContainersApplicationCodeProjectContributor( + ServiceConnections serviceConnections) { + return new JavaTestContainersApplicationCodeProjectContributor(this.indentingWriterFactory, + this.description, serviceConnections); + } - private final IndentingWriterFactory indentingWriterFactory; - - TestApplicationConfiguration(ProjectDescription description, IndentingWriterFactory indentingWriterFactory) { - this.description = description; - this.indentingWriterFactory = indentingWriterFactory; - } - - @Bean - @ConditionalOnLanguage(GroovyLanguage.ID) - GroovyTestContainersApplicationCodeProjectContributor groovyTestContainersApplicationCodeProjectContributor( - ServiceConnections serviceConnections) { - return new GroovyTestContainersApplicationCodeProjectContributor(this.indentingWriterFactory, - this.description, serviceConnections); - } - - @Bean - @ConditionalOnLanguage(KotlinLanguage.ID) - @ConditionalOnPlatformVersion("3.1.1-SNAPSHOT") // https://github.com/spring-projects/spring-boot/issues/35756 - KotlinTestContainersApplicationCodeProjectContributor kotlinTestContainersApplicationCodeProjectContributor( - ServiceConnections serviceConnections) { - return new KotlinTestContainersApplicationCodeProjectContributor(this.indentingWriterFactory, - this.description, serviceConnections); - } - - @Bean - @ConditionalOnLanguage(JavaLanguage.ID) - JavaTestContainersApplicationCodeProjectContributor javaTestContainersApplicationCodeProjectContributor( - ServiceConnections serviceConnections) { - return new JavaTestContainersApplicationCodeProjectContributor(this.indentingWriterFactory, - this.description, serviceConnections); } }