diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/springcloud/SpringCloudStreamBuildCustomizer.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/springcloud/SpringCloudStreamBuildCustomizer.java index 8476da598bd..b0dba745971 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/springcloud/SpringCloudStreamBuildCustomizer.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/springcloud/SpringCloudStreamBuildCustomizer.java @@ -57,6 +57,11 @@ public void customize(Build build) { .add("cloud-stream-binder-kafka", "org.springframework.cloud", "spring-cloud-stream-binder-kafka", DependencyScope.COMPILE); } + if (isSpringBoot3xWithPulsarSupport() && hasDependency("pulsar", build)) { + build.dependencies() + .add("cloud-stream-binder-pulsar", "org.springframework.cloud", "spring-cloud-stream-binder-pulsar", + DependencyScope.COMPILE); + } } // Spring Cloud Stream specific if (hasDependency("cloud-stream", build)) { @@ -92,4 +97,9 @@ protected boolean isSpringBoot3x() { return platformVersion.compareTo(Version.parse("3.0.0-M1")) > 0; } + protected boolean isSpringBoot3xWithPulsarSupport() { + Version platformVersion = this.description.getPlatformVersion(); + return platformVersion.compareTo(Version.parse("3.2.0-M3")) >= 0; + } + } diff --git a/start-site/src/test/java/io/spring/start/site/extension/dependency/springcloud/SpringCloudStreamBuildCustomizerTests.java b/start-site/src/test/java/io/spring/start/site/extension/dependency/springcloud/SpringCloudStreamBuildCustomizerTests.java index ad9bced5034..65687ffd27b 100755 --- a/start-site/src/test/java/io/spring/start/site/extension/dependency/springcloud/SpringCloudStreamBuildCustomizerTests.java +++ b/start-site/src/test/java/io/spring/start/site/extension/dependency/springcloud/SpringCloudStreamBuildCustomizerTests.java @@ -34,6 +34,7 @@ * * @author Stephane Nicoll * @author Brian Clozel + * @author Chris Bono */ class SpringCloudStreamBuildCustomizerTests extends AbstractExtensionTests { @@ -43,6 +44,9 @@ class SpringCloudStreamBuildCustomizerTests extends AbstractExtensionTests { private static final Dependency KAFKA_STREAMS_BINDER = Dependency.withId("cloud-stream-binder-kafka-streams", "org.springframework.cloud", "spring-cloud-stream-binder-kafka-streams"); + private static final Dependency PULSAR_BINDER = Dependency.withId("cloud-stream-binder-pulsar", + "org.springframework.cloud", "spring-cloud-stream-binder-pulsar"); + private static final Dependency RABBIT_BINDER = Dependency.withId("cloud-stream-binder-rabbit", "org.springframework.cloud", "spring-cloud-stream-binder-rabbit"); @@ -85,6 +89,19 @@ void springCloudStreamWithKafkaStreams(Version springBootVersion, Dependency tes .hasDependenciesSize(5); } + @ParameterizedTest + @MethodSource("springCloudStreamWithPulsarArguments") + void springCloudStreamWithPulsar(Version springBootVersion, Dependency testDependency) { + ProjectRequest request = createProjectRequest("cloud-stream", "pulsar"); + request.setBootVersion(springBootVersion.toString()); + assertThat(mavenPom(request)).hasDependency(getDependency("cloud-stream")) + .hasDependency(getDependency("pulsar")) + .hasDependency(PULSAR_BINDER) + .hasDependency(Dependency.createSpringBootStarter("test", Dependency.SCOPE_TEST)) + .hasDependency(testDependency) + .hasDependenciesSize(5); + } + @ParameterizedTest @MethodSource("springCloudStreamArguments") void springCloudStreamWithAllBinders(Version springBootVersion, Dependency testDependency) { @@ -103,20 +120,27 @@ void springCloudStreamWithAllBinders(Version springBootVersion, Dependency testD } @ParameterizedTest - @MethodSource("springCloudStreamArguments") - void springCloudBusWithRabbit(Version springBootVersion, Dependency testDependency) { - ProjectRequest request = createProjectRequest("cloud-bus", "amqp"); + @MethodSource("springCloudStreamWithPulsarArguments") + void springCloudStreamWithAllBindersInBoot32x(Version springBootVersion, Dependency testDependency) { + ProjectRequest request = createProjectRequest("cloud-stream", "amqp", "kafka", "kafka-streams", "pulsar"); request.setBootVersion(springBootVersion.toString()); - assertThat(mavenPom(request)).hasDependency(getDependency("cloud-bus")) + assertThat(mavenPom(request)).hasDependency(getDependency("cloud-stream")) .hasDependency(getDependency("amqp")) + .hasDependency(getDependency("kafka")) + .hasDependency(getDependency("kafka-streams")) + .hasDependency(getDependency("pulsar")) .hasDependency(RABBIT_BINDER) + .hasDependency(KAFKA_BINDER) + .hasDependency(KAFKA_STREAMS_BINDER) + .hasDependency(PULSAR_BINDER) .hasDependency(Dependency.createSpringBootStarter("test", Dependency.SCOPE_TEST)) - .hasDependenciesSize(5); + .hasDependency(testDependency) + .hasDependenciesSize(13); } @ParameterizedTest @MethodSource("springCloudStreamArguments") - void springCloudBusWithKafka(Version springBootVersion, Dependency testDependency) { + void springCloudBusWithRabbit(Version springBootVersion, Dependency ignoredTestDependency) { ProjectRequest request = createProjectRequest("cloud-bus", "amqp"); request.setBootVersion(springBootVersion.toString()); assertThat(mavenPom(request)).hasDependency(getDependency("cloud-bus")) @@ -128,17 +152,43 @@ void springCloudBusWithKafka(Version springBootVersion, Dependency testDependenc @ParameterizedTest @MethodSource("springCloudStreamArguments") - void springCloudBusWithAllBinders(Version springBootVersion, Dependency testDependency) { - ProjectRequest request = createProjectRequest("cloud-bus", "amqp", "kafka", "kafka-streams"); + void springCloudBusWithKafka(Version springBootVersion, Dependency ignoredTestDependency) { + ProjectRequest request = createProjectRequest("cloud-bus", "kafka"); + request.setBootVersion(springBootVersion.toString()); + assertThat(mavenPom(request)).hasDependency(getDependency("cloud-bus")) + .hasDependency(getDependency("kafka")) + .hasDependency(KAFKA_BINDER) + .hasDependency(Dependency.createSpringBootStarter("test", Dependency.SCOPE_TEST)) + .hasDependenciesSize(5); + } + + @ParameterizedTest + @MethodSource("springCloudStreamWithPulsarArguments") + void springCloudBusWithPulsar(Version springBootVersion, Dependency ignoredTestDependency) { + ProjectRequest request = createProjectRequest("cloud-bus", "pulsar"); + request.setBootVersion(springBootVersion.toString()); + assertThat(mavenPom(request)).hasDependency(getDependency("cloud-bus")) + .hasDependency(getDependency("pulsar")) + .hasDependency(PULSAR_BINDER) + .hasDependency(Dependency.createSpringBootStarter("test", Dependency.SCOPE_TEST)) + .hasDependenciesSize(4); + } + + @ParameterizedTest + @MethodSource("springCloudStreamWithPulsarArguments") + void springCloudBusWithAllBindersInBoot32x(Version springBootVersion, Dependency ignoredTestDependency) { + ProjectRequest request = createProjectRequest("cloud-bus", "amqp", "kafka", "kafka-streams", "pulsar"); request.setBootVersion(springBootVersion.toString()); assertThat(mavenPom(request)).hasDependency(getDependency("cloud-bus")) .hasDependency(getDependency("amqp")) .hasDependency(getDependency("kafka")) .hasDependency(getDependency("kafka-streams")) + .hasDependency(getDependency("pulsar")) .hasDependency(RABBIT_BINDER) .hasDependency(KAFKA_BINDER) + .hasDependency(PULSAR_BINDER) .hasDependency(Dependency.createSpringBootStarter("test", Dependency.SCOPE_TEST)) - .hasDependenciesSize(9); + .hasDependenciesSize(11); } @Test @@ -159,4 +209,11 @@ private static Stream springCloudStreamArguments() { Arguments.of(Version.parse("3.0.0"), testBinder)); } + private static Stream springCloudStreamWithPulsarArguments() { + Dependency testBinder = Dependency.withId("cloud-stream-test", "org.springframework.cloud", + "spring-cloud-stream-test-binder", null, Dependency.SCOPE_TEST); + return Stream.of(Arguments.of(Version.parse("3.2.0-M3"), testBinder), + Arguments.of(Version.parse("3.2.0-RC1"), testBinder)); + } + }