diff --git a/src/main/resources/META-INF/rewrite/spring-boot-27.yml b/src/main/resources/META-INF/rewrite/spring-boot-27.yml index 716c74cae..ba5b28c23 100644 --- a/src/main/resources/META-INF/rewrite/spring-boot-27.yml +++ b/src/main/resources/META-INF/rewrite/spring-boot-27.yml @@ -57,6 +57,12 @@ recipeList: groupId: org.springdoc artifactId: "*" newVersion: 1.8.x + # Upgrade Spring Cloud Stream to the release line compatible with Spring Boot 2.7. + - org.openrewrite.java.dependencies.UpgradeDependencyVersion: + groupId: org.springframework.cloud + artifactId: spring-cloud-stream-dependencies + newVersion: 3.2.x + overrideManagedVersion: false # Use recommended replacements for deprecated APIs - org.openrewrite.java.ChangeType: oldFullyQualifiedTypeName: org.springframework.boot.web.server.LocalServerPort diff --git a/src/test/java/org/openrewrite/java/spring/boot2/SpringCloudStreamVersionUpgradeTest.java b/src/test/java/org/openrewrite/java/spring/boot2/SpringCloudStreamVersionUpgradeTest.java new file mode 100644 index 000000000..68bc785d0 --- /dev/null +++ b/src/test/java/org/openrewrite/java/spring/boot2/SpringCloudStreamVersionUpgradeTest.java @@ -0,0 +1,101 @@ +/* + * Copyright 2026 the original author or authors. + *

+ * Licensed under the Moderne Source Available License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://docs.moderne.io/licensing/moderne-source-available-license + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.java.spring.boot2; + +import org.junit.jupiter.api.Test; +import org.openrewrite.Issue; +import org.openrewrite.test.RecipeSpec; +import org.openrewrite.test.RewriteTest; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.openrewrite.maven.Assertions.pomXml; + +class SpringCloudStreamVersionUpgradeTest implements RewriteTest { + + @Override + public void defaults(RecipeSpec spec) { + spec.recipeFromResources("org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_7"); + } + + @Issue("https://github.com/openrewrite/rewrite-spring/issues/672") + @Test + void upgradesSpringCloudStreamBom() { + rewriteRun( + pomXml( + """ + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 1.5.2.RELEASE + + + com.example + demo + 0.0.1-SNAPSHOT + + Fishtown.SR4 + + + + + org.springframework.cloud + spring-cloud-stream-dependencies + ${spring-cloud-stream.version} + pom + import + + + + + """, + spec -> spec.after(actual -> + assertThat(actual) + .containsPattern("3\\.2\\.\\d+") + .actual() + ) + ) + ); + } + + @Test + void doesNotDowngradeNewerSpringCloudStreamBom() { + rewriteRun( + pomXml( + """ + + 4.0.0 + com.example + demo + 0.0.1-SNAPSHOT + + + + org.springframework.cloud + spring-cloud-stream-dependencies + 4.0.0 + pom + import + + + + + """ + ) + ); + } +}