Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UpgradeSpringBoot_3_3 setting wrong Spring Cloud version #537

Open
timbuethe opened this issue Jun 12, 2024 · 6 comments
Open

UpgradeSpringBoot_3_3 setting wrong Spring Cloud version #537

timbuethe opened this issue Jun 12, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@timbuethe
Copy link

I am using

  • OpenRewrite 5.33.0
  • Maven plugin 5.33.0
  • rewrite-spring 5.12.0

I am using the Maven plugin, and my project is a single module project.

             <plugin>
                <groupId>org.openrewrite.maven</groupId>
                <artifactId>rewrite-maven-plugin</artifactId>
                <version>5.33.0</version>
                <configuration>
                    <activeRecipes>
                        <recipe>org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3</recipe>
                    </activeRecipes>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.openrewrite.recipe</groupId>
                        <artifactId>rewrite-spring</artifactId>
                        <version>5.12.0</version>
                    </dependency>
                </dependencies>
            </plugin>

What did you expect to see / What did you see instead?

When running org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_2 Spring Cloud version is set to 2023.0.2, as expected.
But if we run org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3 instead, the version is set to 2021.0.9.

example project to reproduce the issue:

OpenRewriteSpringCloudMigration.zip

@timbuethe timbuethe added the bug Something isn't working label Jun 12, 2024
@timtebeek
Copy link
Contributor

Thanks for reporting this issue here as well! Good to track this going forward. As indicated previously, there should be no reason why change is missing, as the recipes are chained back to back. 🤔

@bsmahi
Copy link
Contributor

bsmahi commented Jun 15, 2024

Hi @timbuethe and @timtebeek,

Have tried to reproduce the issue and here is my observation, in fact it is working fine and changing the spring cloud version to 2023.0.2 for even for the recipe org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3

I have removed the following entry from pom.xml under properties tag <mockito.version>2.18.3</mockito.version>

And then executed dryRun it is here is the outcome with rewrite.patch file where spring cloud version has been changed to 2023.0.2 with UpgradeSpringBoot_3_3 recipe

[INFO] Using active recipe(s) [org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3]
[INFO] Using active styles(s) []
[INFO] Validating active recipes...
[INFO] Project [FooService] Resolving Poms...
[INFO] Project [FooService] Parsing source files
[INFO] Running recipe(s)...
[WARNING] These recipes would make changes to Desktop/OpenRewriteSpringCloudMigration/pom.xml:
[WARNING]     org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3
[WARNING]         org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_2
[WARNING]             org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_1
[WARNING]                 org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_0
[WARNING]                     org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_7
[WARNING]                         org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_6
[WARNING]                             org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_5
[WARNING]                                 org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_4
[WARNING]                                     org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_3
[WARNING]                                         org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_2
[WARNING]                                             org.openrewrite.maven.UpgradeParentVersion: {groupId=org.springframework.boot, artifactId=spring-boot-starter-parent, newVersion=2.2.x}
[WARNING]                                         org.openrewrite.maven.UpgradeParentVersion: {groupId=org.springframework.boot, artifactId=spring-boot-starter-parent, newVersion=2.3.x}
[WARNING]                                     org.openrewrite.java.spring.boot2.SpringBoot2JUnit4to5Migration
[WARNING]                                         org.openrewrite.java.testing.junit5.JUnit4to5Migration
[WARNING]                                             org.openrewrite.maven.ExcludeDependency: {groupId=junit, artifactId=junit}
[WARNING]                                             org.openrewrite.maven.ExcludeDependency: {groupId=org.junit.vintage, artifactId=junit-vintage-engine}
[WARNING]                                     org.openrewrite.maven.UpgradeParentVersion: {groupId=org.springframework.boot, artifactId=spring-boot-starter-parent, newVersion=2.4.x}
[WARNING]                                     org.openrewrite.maven.RemoveExclusion: {groupId=org.springframework.boot, artifactId=spring-boot-starter-test, exclusionGroupId=org.junit.vintage, exclusionArtifactId=junit-vintage-engine}
[WARNING]                                     org.openrewrite.maven.RemoveExclusion: {groupId=org.springframework.boot, artifactId=spring-boot-starter-test, exclusionGroupId=junit, exclusionArtifactId=junit}
[WARNING]                                 org.openrewrite.maven.UpgradeParentVersion: {groupId=org.springframework.boot, artifactId=spring-boot-starter-parent, newVersion=2.5.x}
[WARNING]                             org.openrewrite.maven.UpgradeParentVersion: {groupId=org.springframework.boot, artifactId=spring-boot-starter-parent, newVersion=2.6.x}
[WARNING]                             org.openrewrite.java.dependencies.UpgradeDependencyVersion: {groupId=org.springframework.cloud, artifactId=spring-cloud-dependencies, newVersion=2021.0.X, overrideManagedVersion=false}
[WARNING]                         org.openrewrite.maven.UpgradeParentVersion: {groupId=org.springframework.boot, artifactId=spring-boot-starter-parent, newVersion=2.7.x}
[WARNING]                     org.openrewrite.java.migrate.UpgradeToJava17
[WARNING]                         org.openrewrite.java.migrate.UpgradeBuildToJava17
[WARNING]                             org.openrewrite.java.migrate.UpgradeJavaVersion: {version=17}
[WARNING]                                 org.openrewrite.java.migrate.maven.UpdateMavenProjectPropertyJavaVersion: {version=17}
[WARNING]                     org.openrewrite.maven.UpgradeParentVersion: {groupId=org.springframework.boot, artifactId=spring-boot-starter-parent, newVersion=3.0.x}
[WARNING]                     org.openrewrite.java.spring.cloud2022.UpgradeSpringCloud_2022
[WARNING]                         org.openrewrite.java.spring.cloud2022.DependencyUpgrades
[WARNING]                             org.openrewrite.java.dependencies.UpgradeDependencyVersion: {groupId=org.springframework.cloud, artifactId=spring-cloud-dependencies, newVersion=2022.0.x, overrideManagedVersion=false}
[WARNING]                 org.openrewrite.maven.UpgradeParentVersion: {groupId=org.springframework.boot, artifactId=spring-boot-starter-parent, newVersion=3.1.x}
[WARNING]             org.openrewrite.maven.UpgradeParentVersion: {groupId=org.springframework.boot, artifactId=spring-boot-starter-parent, newVersion=3.2.x}
[WARNING]             org.openrewrite.java.spring.cloud2023.UpgradeSpringCloud_2023
[WARNING]                 org.openrewrite.java.spring.cloud2023.DependencyUpgrades
[WARNING]                     org.openrewrite.java.dependencies.UpgradeDependencyVersion: {groupId=org.springframework.cloud, artifactId=spring-cloud-dependencies, newVersion=2023.0.x, overrideManagedVersion=false}
[WARNING]         org.openrewrite.maven.UpgradeParentVersion: {groupId=org.springframework.boot, artifactId=spring-boot-starter-parent, newVersion=3.3.x}
[WARNING] Patch file available:
[WARNING]     /Users/puneethsai/Desktop/OpenRewriteSpringCloudMigration/target/rewrite/rewrite.patch

rewrite.patch file

diff --git a/Desktop/OpenRewriteSpringCloudMigration/pom.xml b/Desktop/OpenRewriteSpringCloudMigration/pom.xml
index a20976a..3c462e9 100644
--- a/Desktop/OpenRewriteSpringCloudMigration/pom.xml
+++ b/Desktop/OpenRewriteSpringCloudMigration/pom.xml
@@ -12,13 +12,13 @@ org.openrewrite.config.CompositeRecipe
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>2.2.2.RELEASE</version>
+        <version>3.3.0</version>
         <relativePath/>
     </parent>
 
     <properties>
-        <java.version>11</java.version>
-        <spring-cloud.version>Hoxton.SR9</spring-cloud.version>
+        <java.version>17</java.version>
+        <spring-cloud.version>2023.0.2</spring-cloud.version>
     </properties>
 
     <dependencyManagement>

See spring cloud version has been migrated to 2023.0.2
<spring-cloud.version>2023.0.2</spring-cloud.version>

@timbuethe I hope that helps, could you please try from your side and let me know your thoughts.

If it is working fine, we can close this issue.

Thanks,
Mahendra

@timtebeek
Copy link
Contributor

Thanks a lot @bsmahi ! Very helpful to know that it's working in your case, so it's not inherent to the recipes themselves, but something perhaps with the specific project at hand.

@timbuethe
Copy link
Author

Yes, I can confirm that it is working as expected when removing the <mockito.version>2.18.3</mockito.version> property and it is not working when the property is included. So, it seems to be working in some cases but is buggy in others.

That's very unfortunate, as our original plan was to automate the updates for a large number of services. If we can not trust a successful run and need to double check versions etc. it will be a lot of manual effort.

@timtebeek
Copy link
Contributor

That's a very unexpected interplay there with that Mockito version; rest assured that we very much want to see this resolved, as running across a lot of repositories is core to what we do at Moderne. I wonder if we can reduce this to a unit test to be able to test this more easily, and guarantee that it's fixed going forward.

@timbuethe
Copy link
Author

timbuethe commented Jun 16, 2024

I created this PR, setting up Spring Boot 3.3 tests and adding a test case for the problem described above.

I wasn't sure if the test should execute org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3 or rather just the included recipe org.openrewrite.java.spring.cloud2023.DependencyUpgrades or org.openrewrite.java.spring.cloud2023.UpgradeSpringCloud_2023. I'm happy to adjust the PR if you point me into the right direction or you grab it and change whatever you want.

timbuethe added a commit to freenowtech/rewrite-spring that referenced this issue Jun 16, 2024
timbuethe added a commit to freenowtech/rewrite-spring that referenced this issue Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

3 participants