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 39a7ef91d7c..2760490fe6a 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,6 +16,9 @@ package io.spring.start.site.extension.dependency.springpulsar; +import java.util.Map; + +import io.spring.initializr.generator.buildsystem.Dependency; import io.spring.initializr.generator.condition.ConditionalOnPlatformVersion; import io.spring.initializr.generator.condition.ConditionalOnRequestedDependency; import io.spring.initializr.generator.condition.ProjectGenerationCondition; @@ -26,6 +29,7 @@ import io.spring.start.site.container.DockerServiceResolver; import io.spring.start.site.container.ServiceConnections; import io.spring.start.site.container.ServiceConnectionsCustomizer; +import io.spring.start.site.extension.dependency.springpulsar.SpringPulsarProjectGenerationConfiguration.OnPulsarDependencyCondition; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ConditionContext; @@ -38,13 +42,13 @@ * @author Chris Bono */ @ProjectGenerationConfiguration -@Conditional(SpringPulsarProjectGenerationConfiguration.OnPulsarRequestedDependencyCondition.class) +@Conditional(OnPulsarDependencyCondition.class) class SpringPulsarProjectGenerationConfiguration { private static final String TESTCONTAINERS_CLASS_NAME = "org.testcontainers.containers.PulsarContainer"; @Bean - @ConditionalOnPlatformVersion("3.2.0-SNAPSHOT") + @ConditionalOnPlatformVersion("3.2.0-M3") @ConditionalOnRequestedDependency("testcontainers") ServiceConnectionsCustomizer pulsarServiceConnectionsCustomizer(DockerServiceResolver serviceResolver) { return (serviceConnections) -> serviceResolver.doWith("pulsar", @@ -53,7 +57,7 @@ ServiceConnectionsCustomizer pulsarServiceConnectionsCustomizer(DockerServiceRes } @Bean - @ConditionalOnPlatformVersion("3.2.0-SNAPSHOT") + @ConditionalOnPlatformVersion("3.2.0-M3") @ConditionalOnRequestedDependency("docker-compose") ComposeFileCustomizer pulsarComposeFileCustomizer(DockerServiceResolver serviceResolver) { return (composeFile) -> serviceResolver.doWith("pulsar", @@ -68,13 +72,13 @@ SpringPulsarBinderBuildCustomizer pulsarBinderBuildCustomizer(InitializrMetadata return new SpringPulsarBinderBuildCustomizer(metadata, description); } - static class OnPulsarRequestedDependencyCondition extends ProjectGenerationCondition { + static class OnPulsarDependencyCondition extends ProjectGenerationCondition { @Override protected boolean matches(ProjectDescription description, ConditionContext context, AnnotatedTypeMetadata metadata) { - return description.getRequestedDependencies().containsKey("pulsar") - || description.getRequestedDependencies().containsKey("pulsar-reactive"); + Map requestedDependencies = description.getRequestedDependencies(); + return requestedDependencies.containsKey("pulsar") || requestedDependencies.containsKey("pulsar-reactive"); } } diff --git a/start-site/src/main/resources/application.yml b/start-site/src/main/resources/application.yml index 0cc52470bf2..91f7138ad57 100644 --- a/start-site/src/main/resources/application.yml +++ b/start-site/src/main/resources/application.yml @@ -786,20 +786,19 @@ initializr: href: https://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/index.html#messaging.jms.artemis - name: Spring for Apache Pulsar id: pulsar - compatibilityRange: "[3.0.0,3.2.0-SNAPSHOT]" + compatibilityRange: "3.0.0" description: Build messaging applications with Apache Pulsar links: - rel: reference href: https://docs.spring.io/spring-boot/docs/{bootVersion}/reference/htmlsingle/index.html#messaging.pulsar mappings: - - compatibilityRange: "[3.0.0,3.2.0-M1)" + - compatibilityRange: "[3.0.0,3.2.0-M3)" version: 0.2.0 groupId: org.springframework.pulsar artifactId: spring-pulsar-spring-boot-starter - starter: false - name: Spring for Apache Pulsar (Reactive) id: pulsar-reactive - compatibilityRange: "[3.0.0,3.2.0-SNAPSHOT]" + compatibilityRange: "3.0.0" description: Build reactive messaging applications with Apache Pulsar facets: - reactive @@ -811,7 +810,6 @@ initializr: version: 0.2.0 groupId: org.springframework.pulsar artifactId: spring-pulsar-reactive-spring-boot-starter - starter: false - name: WebSocket id: websocket description: Build Servlet-based WebSocket applications with SockJS and STOMP. diff --git a/start-site/src/test/java/io/spring/start/site/extension/dependency/springpulsar/SpringPulsarProjectGenerationConfigurationTests.java b/start-site/src/test/java/io/spring/start/site/extension/dependency/springpulsar/SpringPulsarProjectGenerationConfigurationTests.java index d3d15139255..9a6090f01db 100644 --- a/start-site/src/test/java/io/spring/start/site/extension/dependency/springpulsar/SpringPulsarProjectGenerationConfigurationTests.java +++ b/start-site/src/test/java/io/spring/start/site/extension/dependency/springpulsar/SpringPulsarProjectGenerationConfigurationTests.java @@ -70,7 +70,7 @@ void pulsarReactiveLegacyStarterUsedWhenBoot30orBoot31Selected(String bootVersio @Test void pulsarBootStarterUsedWhenBoot32Selected() { ProjectRequest request = createProjectRequest("pulsar"); - request.setBootVersion("3.2.0-SNAPSHOT"); + request.setBootVersion("3.2.0-M3"); ProjectStructure project = generateProject(request); assertThat(project).mavenBuild().hasDependency("org.springframework.boot", "spring-boot-starter-pulsar"); } @@ -78,7 +78,7 @@ void pulsarBootStarterUsedWhenBoot32Selected() { @Test void pulsarReactiveBootStarterUsedWhenBoot32Selected() { ProjectRequest request = createProjectRequest("pulsar-reactive"); - request.setBootVersion("3.2.0-SNAPSHOT"); + request.setBootVersion("3.2.0-M3"); ProjectStructure project = generateProject(request); assertThat(project).mavenBuild() .hasDependency("org.springframework.boot", "spring-boot-starter-pulsar-reactive"); @@ -92,7 +92,7 @@ class DockerComposeConfigurationTests { @Test void serviceNotCreatedWhenDockerComposeNotSelected() { ProjectRequest request = createProjectRequest("pulsar"); - request.setBootVersion("3.2.0-SNAPSHOT"); + request.setBootVersion("3.2.0-M3"); ProjectStructure structure = generateProject(request); assertThat(structure.getProjectDirectory().resolve("compose.yaml")).doesNotExist(); } @@ -109,7 +109,7 @@ void serviceNotCreatedWhenIncompatibleBootVersionSelected(String bootVersion) { @ValueSource(strings = { "pulsar", "pulsar-reactive" }) void serviceCreatedWhenDockerComposeSelectedWithCompatibleBootVersion(String pulsarDependencyId) { ProjectRequest request = createProjectRequest("docker-compose", pulsarDependencyId); - request.setBootVersion("3.2.0-SNAPSHOT"); + request.setBootVersion("3.2.0-M3"); assertThat(composeFile(request)).hasSameContentAs(new ClassPathResource("compose/pulsar.yaml")); } @@ -120,12 +120,12 @@ class ServiceConnectionConfigurationTests { private final ProjectAssetTester projectTester = new ProjectAssetTester() .withConfiguration(SpringPulsarProjectGenerationConfiguration.class) - .withBean(DockerServiceResolver.class, () -> new SimpleDockerServiceResolver()); + .withBean(DockerServiceResolver.class, SimpleDockerServiceResolver::new); @Test void connectionNotAddedWhenTestcontainersNotSelected() { MutableProjectDescription description = new MutableProjectDescription(); - description.setPlatformVersion(Version.parse("3.2.0-SNAPSHOT")); + description.setPlatformVersion(Version.parse("3.2.0-M3")); description.addDependency("pulsar", mock(Dependency.class)); this.projectTester.configure(description, (context) -> assertThat(context).doesNotHaveBean("pulsarServiceConnectionsCustomizer")); @@ -134,7 +134,7 @@ void connectionNotAddedWhenTestcontainersNotSelected() { @Test void connectionNotAddedWhenPulsarNotSelected() { MutableProjectDescription description = new MutableProjectDescription(); - description.setPlatformVersion(Version.parse("3.2.0-SNAPSHOT")); + description.setPlatformVersion(Version.parse("3.2.0-M3")); description.addDependency("testcontainers", mock(Dependency.class)); this.projectTester.configure(description, (context) -> assertThat(context).doesNotHaveBean("pulsarServiceConnectionsCustomizer")); @@ -155,7 +155,7 @@ void connectionNotAddedWhenIncompatibleBootVersionSelected(String bootVersion) { @ValueSource(strings = { "pulsar", "pulsar-reactive" }) void connectionAddedWhenTestcontainersAndPulsarSelectedWithCompatibleBootVersion(String pulsarDependencyId) { MutableProjectDescription description = new MutableProjectDescription(); - description.setPlatformVersion(Version.parse("3.2.0-SNAPSHOT")); + description.setPlatformVersion(Version.parse("3.2.0-M3")); description.addDependency("testcontainers", mock(Dependency.class)); description.addDependency(pulsarDependencyId, mock(Dependency.class)); this.projectTester.configure(description, @@ -164,11 +164,11 @@ void connectionAddedWhenTestcontainersAndPulsarSelectedWithCompatibleBootVersion .satisfies((customizer) -> { ServiceConnections connections = new ServiceConnections(); customizer.customize(connections); - assertPulsarServiceConnectionAddded(connections); + assertPulsarServiceConnectionAdded(connections); })); } - private void assertPulsarServiceConnectionAddded(ServiceConnections connections) { + private void assertPulsarServiceConnectionAdded(ServiceConnections connections) { assertThat(connections.values()).first().satisfies((connection) -> { assertThat(connection.id()).isEqualTo("pulsar"); assertThat(connection.containerClassName()).isEqualTo("org.testcontainers.containers.PulsarContainer"); @@ -208,7 +208,7 @@ void binderNotAddedWhenPulsarNotSelected() { } @ParameterizedTest - @ValueSource(strings = { "3.2.0-M1", "3.2.0-SNAPSHOT" }) + @ValueSource(strings = { "3.2.0-M1", "3.2.0-M3" }) void binderNotAddedWhenPulsarAndCloudStreamSelectedWithIncompatibleBootVersion(String bootVersion) { ProjectRequest request = createProjectRequest("pulsar", "cloud-stream"); request.setBootVersion(bootVersion); @@ -217,7 +217,7 @@ void binderNotAddedWhenPulsarAndCloudStreamSelectedWithIncompatibleBootVersion(S } @ParameterizedTest - @ValueSource(strings = { "3.0.0", "3.1.3", "3.1.4-SNAPSHOT" }) + @ValueSource(strings = { "3.0.0", "3.1.3" }) void binderAddedWhenPulsarAndCloudStreamSelectedWithCompatibleBootVersion(String bootVersion) { ProjectRequest request = createProjectRequest("pulsar", "cloud-stream"); request.setBootVersion(bootVersion); @@ -226,7 +226,7 @@ void binderAddedWhenPulsarAndCloudStreamSelectedWithCompatibleBootVersion(String } @ParameterizedTest - @ValueSource(strings = { "3.0.0", "3.1.3", "3.1.4-SNAPSHOT" }) + @ValueSource(strings = { "3.0.0", "3.1.3" }) void binderAddedWhenPulsarReactiveAndCloudStreamSelectedWithCompatibleBootVersion(String bootVersion) { ProjectRequest request = createProjectRequest("pulsar-reactive", "cloud-stream"); request.setBootVersion(bootVersion); diff --git a/start-site/src/test/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersProjectGenerationConfigurationTests.java b/start-site/src/test/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersProjectGenerationConfigurationTests.java index fd87356cb0f..cfb811a1358 100644 --- a/start-site/src/test/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersProjectGenerationConfigurationTests.java +++ b/start-site/src/test/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersProjectGenerationConfigurationTests.java @@ -20,6 +20,7 @@ import io.spring.initializr.generator.test.io.TextAssert; import io.spring.initializr.generator.test.project.ProjectStructure; +import io.spring.initializr.generator.version.Version; import io.spring.initializr.web.project.ProjectRequest; import io.spring.start.site.extension.AbstractExtensionTests; import org.junit.jupiter.api.Test; @@ -51,7 +52,7 @@ void buildWithOnlyTestContainers() { void buildWithSupportedEntries(String springBootDependencyId, String testcontainersArtifactId) { assertThat(generateProject("3.0.0", "testcontainers", springBootDependencyId)).mavenBuild() .hasBom("org.testcontainers", "testcontainers-bom", "${testcontainers.version}") - .hasDependency(getDependency(springBootDependencyId)) + .hasDependency(getDependency(springBootDependencyId).resolve(Version.parse("3.0.0"))) .hasDependency("org.testcontainers", testcontainersArtifactId, null, "test") .hasDependency(getDependency("testcontainers")); }