Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
mhalbritter committed Sep 13, 2024
1 parent d33a2c4 commit 5bd5a72
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -43,22 +47,35 @@ 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<Build> springAiDockerComposeBuildCustomizer(InitializrMetadata metadata,
ProjectDescription description) {
BuildCustomizer<Build> 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")
.version(VersionReference.ofProperty(springAiBomVersion))
.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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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);
}

}

}

0 comments on commit 5bd5a72

Please sign in to comment.