diff --git a/start-site/src/main/java/io/spring/start/site/container/SimpleDockerServiceResolver.java b/start-site/src/main/java/io/spring/start/site/container/SimpleDockerServiceResolver.java index f81853f084b..f67fe0344ee 100644 --- a/start-site/src/main/java/io/spring/start/site/container/SimpleDockerServiceResolver.java +++ b/start-site/src/main/java/io/spring/start/site/container/SimpleDockerServiceResolver.java @@ -41,6 +41,7 @@ public SimpleDockerServiceResolver() { this.dockerServices.put("mysql", mysql()); this.dockerServices.put("oracle", oracle()); this.dockerServices.put("postgres", postgres()); + this.dockerServices.put("pulsar", pulsar()); this.dockerServices.put("rabbit", rabbit()); this.dockerServices.put("redis", redis()); this.dockerServices.put("sqlServer", sqlServer()); @@ -86,6 +87,11 @@ private static DockerService postgres() { return new DockerService("postgres", "latest", "https://hub.docker.com/_/postgres", 5432); } + private static DockerService pulsar() { + return new DockerService("apachepulsar/pulsar", "latest", "https://hub.docker.com/r/apachepulsar/pulsar", 6650, + 8080); + } + private static DockerService rabbit() { return new DockerService("rabbitmq", "latest", "https://hub.docker.com/_/rabbitmq", 5672); } diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/springpulsar/SpringPulsarProjectGenerationConfiguration.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/springpulsar/SpringPulsarProjectGenerationConfiguration.java index 38fc039d8b5..c3a91f7b29d 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/springpulsar/SpringPulsarProjectGenerationConfiguration.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/springpulsar/SpringPulsarProjectGenerationConfiguration.java @@ -16,17 +16,23 @@ package io.spring.start.site.extension.dependency.springpulsar; +import io.spring.initializr.generator.condition.ConditionalOnPlatformVersion; 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.metadata.InitializrMetadata; +import io.spring.start.site.container.ComposeFileCustomizer; +import io.spring.start.site.container.DockerServiceResolver; +import io.spring.start.site.container.ServiceConnections; +import io.spring.start.site.container.ServiceConnectionsCustomizer; import org.springframework.context.annotation.Bean; /** * Configuration for generation of projects that depend on Pulsar. * * @author Chris Bono + * @author EddĂș MelĂ©ndez */ @ProjectGenerationConfiguration @ConditionalOnRequestedDependency("pulsar") @@ -39,4 +45,20 @@ SpringPulsarBinderBuildCustomizer pulsarBinderBuildCustomizer(InitializrMetadata return new SpringPulsarBinderBuildCustomizer(metadata, description); } + @Bean + @ConditionalOnRequestedDependency("testcontainers") + @ConditionalOnPlatformVersion("3.2.0-SNAPSHOT") + ServiceConnectionsCustomizer pulsarServiceConnectionsCustomizer(DockerServiceResolver serviceResolver) { + return (serviceConnections) -> serviceResolver.doWith("pulsar", + (service) -> serviceConnections.addServiceConnection(ServiceConnections.ServiceConnection + .ofContainer("pulsar", service, "org.testcontainers.containers.PulsarContainer", false))); + } + + @Bean + @ConditionalOnRequestedDependency("docker-compose") + ComposeFileCustomizer pulsarComposeFileCustomizer(DockerServiceResolver serviceResolver) { + return (composeFile) -> serviceResolver.doWith("pulsar", + (service) -> composeFile.services().add("pulsar", service)); + } + }