diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiDockerComposeProjectGenerationConfiguration.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiDockerComposeProjectGenerationConfiguration.java index 85e90d580b0..704b76a13b0 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiDockerComposeProjectGenerationConfiguration.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiDockerComposeProjectGenerationConfiguration.java @@ -19,10 +19,14 @@ import io.spring.initializr.generator.buildsystem.Build; import io.spring.initializr.generator.buildsystem.Dependency; import io.spring.initializr.generator.buildsystem.DependencyScope; +import io.spring.initializr.generator.buildsystem.gradle.GradleBuildSystem; +import io.spring.initializr.generator.buildsystem.maven.MavenBuildSystem; +import io.spring.initializr.generator.condition.ConditionalOnBuildSystem; import io.spring.initializr.generator.condition.ConditionalOnRequestedDependency; -import io.spring.initializr.generator.project.ProjectDescription; import io.spring.initializr.generator.project.ProjectGenerationConfiguration; import io.spring.initializr.generator.spring.build.BuildCustomizer; +import io.spring.initializr.generator.spring.build.gradle.DevelopmentOnlyDependencyGradleBuildCustomizer; +import io.spring.initializr.generator.spring.build.maven.OptionalDependencyMavenBuildCustomizer; import io.spring.initializr.generator.version.VersionProperty; import io.spring.initializr.generator.version.VersionReference; import io.spring.initializr.metadata.InitializrMetadata; @@ -43,14 +47,13 @@ public class SpringAiDockerComposeProjectGenerationConfiguration { * Dependency id of * {@code org.springframework.ai:spring-ai-spring-boot-docker-compose}. */ - public static final String DEPENDENCY_ID = "spring-ai-docker-compose"; + private static final String DEPENDENCY_ID = "spring-ai-docker-compose"; @Bean - BuildCustomizer springAiDockerComposeBuildCustomizer(InitializrMetadata metadata, - ProjectDescription description) { + BuildCustomizer springAiDockerComposeBuildCustomizer(InitializrMetadata metadata) { // spring-ai-spring-boot-docker-compose is not managed in the BOM // See https://github.com/spring-projects/spring-ai/issues/1314 - VersionProperty springAiBomVersion = getSpringAiVersion(metadata, description); + VersionProperty springAiBomVersion = getSpringAiVersion(metadata); return (build) -> build.dependencies() .add(DEPENDENCY_ID, Dependency.withCoordinates("org.springframework.ai", "spring-ai-spring-boot-docker-compose") @@ -58,7 +61,21 @@ BuildCustomizer springAiDockerComposeBuildCustomizer(InitializrMetadata m .scope(DependencyScope.RUNTIME)); } - private static VersionProperty getSpringAiVersion(InitializrMetadata metadata, ProjectDescription description) { + @Bean + @ConditionalOnBuildSystem(GradleBuildSystem.ID) + DevelopmentOnlyDependencyGradleBuildCustomizer springAiDockerComposeGradleBuildCustomizer() { + return new DevelopmentOnlyDependencyGradleBuildCustomizer( + SpringAiDockerComposeProjectGenerationConfiguration.DEPENDENCY_ID); + } + + @Bean + @ConditionalOnBuildSystem(MavenBuildSystem.ID) + OptionalDependencyMavenBuildCustomizer springAiDockerComposeMavenBuildCustomizer() { + return new OptionalDependencyMavenBuildCustomizer( + SpringAiDockerComposeProjectGenerationConfiguration.DEPENDENCY_ID); + } + + private static VersionProperty getSpringAiVersion(InitializrMetadata metadata) { return metadata.getConfiguration().getEnv().getBoms().get("spring-ai").getVersionProperty(); } diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/springboot/SpringBootProjectGenerationConfiguration.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/springboot/SpringBootProjectGenerationConfiguration.java index 7d0f3b7ac9a..eecae228c65 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/springboot/SpringBootProjectGenerationConfiguration.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/springboot/SpringBootProjectGenerationConfiguration.java @@ -23,7 +23,6 @@ import io.spring.initializr.generator.project.ProjectGenerationConfiguration; import io.spring.initializr.generator.spring.build.gradle.DevelopmentOnlyDependencyGradleBuildCustomizer; import io.spring.initializr.generator.spring.build.maven.OptionalDependencyMavenBuildCustomizer; -import io.spring.start.site.extension.dependency.springai.SpringAiDockerComposeProjectGenerationConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -53,18 +52,6 @@ OptionalDependencyMavenBuildCustomizer dockerComposeMavenBuildCustomizer() { return new OptionalDependencyMavenBuildCustomizer("docker-compose"); } - /** - * Marks {@code org.springframework.ai:spring-ai-spring-boot-docker-compose} as - * optional. - * @return the build customizer - * @see SpringAiDockerComposeProjectGenerationConfiguration - */ - @Bean - OptionalDependencyMavenBuildCustomizer springAiDockerComposeMavenBuildCustomizer() { - return new OptionalDependencyMavenBuildCustomizer( - SpringAiDockerComposeProjectGenerationConfiguration.DEPENDENCY_ID); - } - } @Configuration(proxyBeanMethods = false) @@ -83,18 +70,6 @@ DevelopmentOnlyDependencyGradleBuildCustomizer dockerComposeGradleBuildCustomize return new DevelopmentOnlyDependencyGradleBuildCustomizer("docker-compose"); } - /** - * Puts {@code org.springframework.ai:spring-ai-spring-boot-docker-compose} in - * {@code developmentOnly} scope. - * @return the build customizer - * @see SpringAiDockerComposeProjectGenerationConfiguration - */ - @Bean - DevelopmentOnlyDependencyGradleBuildCustomizer springAiDockerComposeGradleBuildCustomizer() { - return new DevelopmentOnlyDependencyGradleBuildCustomizer( - SpringAiDockerComposeProjectGenerationConfiguration.DEPENDENCY_ID); - } - } }