Repository navigation
Make three Spring migration recipes converge in a single cycle - #1192
Merged
Merged
Conversation
- MigrateLocalServerPortAnnotation: drop the AddDependency step. It scanned for the type the recipe itself creates, and no dependency is needed: both LocalServerPort packages ship in the spring-boot artifact. - AddSpringBootStarterValidation: the jakarta.validation-api precondition also matched the copy Spring Boot 2.2's web starter brings in transitively, which the parent upgrade removes. Match only direct declarations, and also skip modules that declare hibernate-validator. - UpgradeSpringCloud_2025_1: ChangeParentPom retains the old parent's managed Spring Cloud versions, so upgrade org.springframework.cloud:* after it. The tests no longer need expectedCyclesThatMakeChanges(2).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three recipe tests carried
expectedCyclesThatMakeChanges(2): a single run ofUpgradeSpringBoot_2_3,UpgradeSpringBoot_2_0(viaMigrateLocalServerPortAnnotation) orUpgradeSpringCloud_2025_1left a change for a second run. In each case a step decided from source state that an earlier step in the same cycle was about to change. None of them is iterative by design.MigrateLocalServerPortAnnotation: drop the dependency stepIts
AddDependencychild addedspring-boot-starter-webonly if the code used the newweb.server.LocalServerPorttype, which exists only after this recipe's own edit. Rather than retrigger it on the old type, the step is gone, because the move needs no dependency. Both packages ship in thespring-bootartifact:Retriggering would also have started adding starter-web in the 2.7+ chains, which move the annotation on to
spring-boot-testin the same cycle. #541 was a bug in this very addition, and its test now asserts the pom is left alone.AddSpringBootStarterValidation: match declared dependencies onlyThe "skip if
jakarta.validation-apiis present" precondition also matched the copy Boot 2.2's web starter brings in throughspring-boot-starter-validation. The parent upgrade to 2.3 removes it, so the starter was added on the second cycle. #439 asked to skip when the API is declared, so the precondition now setsonlyDirect: true.A module that declares
hibernate-validatoritself had been skipped through that same transitive match. A second precondition keeps skipping it. With Boot 2.3,spring-boot-starter-tomcatstill bringsjakarta.el, so a declared provider works without the starter.A module whose only validation API comes transitively from some other library now gets the starter. The API alone does not enforce constraints, so that is the intended outcome.
UpgradeSpringCloud_2025_1: upgrade after swapping the parentChangeParentPomkeeps the old parent's managed versions it would otherwise lose, e.g.spring-cloud-starter-config:4.3.0, by writing them into<dependencyManagement>. Theorg.springframework.cloud:* → 5.0.xupgrade ran before it and only bumped that entry on the second cycle, so it now runs after it. A multi-module build and a BOM version taken from${spring-cloud.version}also converge in one cycle with this order.The three tests now run with the default one cycle.
shouldNotAddValidationStarterIfHibernateValidatorDeclaredis new and fails without the second precondition.