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

Spring Boot 2.0 - moving the precondition to run in more cases #555

Merged
merged 3 commits into from
Jul 22, 2024

Conversation

nmck257
Copy link
Collaborator

@nmck257 nmck257 commented Jul 22, 2024

What's changed?

narrowing the precondition on the SB 2.0 recipe to ensure it runs more consistently.

What's your motivation?

https://github.com/openrewrite/rewrite-spring/pull/543/files#r1678212731

Anything in particular you'd like reviewers to focus on?

the new precondition is better, but does have a false positive if running the 2.2 recipe on a 2.2 project and a false negative if running the 2.7 recipe on a 2.7 project. this is hard to avoid. the javax.validation-api dep is necessary for SB 2.3 (when hibernate-validator 6.1 swaps its transitive dep from javax to jakarta) through SB 2.7 until SB 3.0 (when spring swaps to jakarta). and with this recipe's placement, it has to make an educated guess about the "final" version of SB for the project after all other recipes in the chain complete while only knowing the current version.

Anyone you would like to review specifically?

@BoykoAlex

Have you considered any alternatives or workarounds?

a nice counterbalance to this recipe might be if the rewrite-migrate-java javax->jakarta migration removed direct jakarta deps which are also available transitively, after it converts javax deps to jakarta. this would help untangle a pom which previously used spring-boot-starter-validation plus javax.validation-api. in the current state, the javax->jakarta recipe leaves such a pom with a redundant jakarta.validation-api which the starter already has covered.

Any additional context

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

Nick McKinney added 2 commits July 19, 2024 16:12
…e consistently. the new precondition is better, but does have a false positive if running the 2.2 recipe on a 2.2 project and a false negative if running the 2.7 recipe on a 2.7 project. this is hard to avoid. the javax.validation-api dep is necessary for SB 2.3 (when hibernate-validator 6.1 swaps its transitive dep from javax to jakarta) through SB 2.7 until SB 3.0 (when spring swaps to jakarta). and with this recipe's placement, it has to make an educated guess about the "final" version of SB for the project after all other recipes in the chain complete while only knowing the current version.
@timtebeek timtebeek added bug Something isn't working enhancement New feature or request labels Jul 22, 2024
build.gradle.kts Outdated
@@ -144,6 +144,7 @@ dependencies {
"testWithSpringBoot_1_5RuntimeOnly"("org.springframework.boot:spring-boot:1.5.+")
"testWithSpringBoot_1_5RuntimeOnly"("org.springframework.boot:spring-boot-autoconfigure:1.5.+")
"testWithSpringBoot_1_5RuntimeOnly"("org.springframework.boot:spring-boot-test:1.5.+")
"testWithSpringBoot_1_5RuntimeOnly"("org.hibernate.validation:hibernate-validator:1.5.+")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build fails. Try:

    "testWithSpringBoot_1_5RuntimeOnly"("org.hibernate:hibernate-validator:5.3.+")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops, was deciding between using the hibernate dep or the spring boot starter dep, and left it in an invalid state.
I've changed it to reference the starter, but can swap both to reference hibernate instead if you have a strong preference.

@nmck257 nmck257 merged commit 4453c04 into main Jul 22, 2024
2 checks passed
@nmck257 nmck257 deleted the feature/sb2-javax-validation-api-enhancements branch July 22, 2024 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants