Skip to content

Add Spring Data MongoDB 5 dependency alignment#1089

Merged
timtebeek merged 3 commits into
openrewrite:mainfrom
Kyran121:migrate-spring-data-mongodb-5
Jul 22, 2026
Merged

Add Spring Data MongoDB 5 dependency alignment#1089
timtebeek merged 3 commits into
openrewrite:mainfrom
Kyran121:migrate-spring-data-mongodb-5

Conversation

@Kyran121

@Kyran121 Kyran121 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What changed

  • This branch is based directly on the current upstream main; the Spring Data 4 foundation from Introduce Spring Data 4 migration foundation #1087 is already merged.

  • Add org.openrewrite.java.spring.data.MigrateSpringDataMongoDb5.

  • Compose it into UpgradeSpringData_4_0.

  • Scope the recipe to modules that resolve org.springframework.data:spring-data-mongodb, including transitive use through Spring Boot MongoDB starters.

  • Upgrade explicitly versioned or unmanaged spring-data-mongodb 4.x dependencies to 5.0.x.

  • Align explicitly pinned, supported MongoDB Java Driver dependencies below 5.6 to 5.6.x.

  • Keep managed, versionless dependencies versionless and remove stale explicit overrides when Spring Boot supplies the compatible target.

  • Preserve compatible forward overrides.

  • Leave MongoDB driver-only modules and deliberately excluded driver artifacts unchanged.

  • Regenerate src/main/resources/META-INF/rewrite/recipes.csv using recipeCsvGenerate.

Explicit MongoDB allow-list

The recipe aligns only these explicitly declared artifacts to 5.6.x:

  • org.mongodb:mongodb-driver-bom
  • org.mongodb:mongodb-driver-core
  • org.mongodb:mongodb-driver-sync
  • org.mongodb:mongodb-driver-reactivestreams
  • org.mongodb:mongodb-crypt
  • org.mongodb:bson
  • org.mongodb:bson-record-codec
  • org.mongodb:mongodb-driver-legacy

Boundary decisions

  • mongodb-driver-bom is upgraded first, while dependencies managed by the BOM remain versionless.
  • mongodb-driver-legacy is version-aligned but is not replaced with mongodb-driver-sync; artifact and API replacement belongs in a separate source migration.
  • The removed org.mongodb:mongo-java-driver uber JAR is not rewritten to a nonexistent 5.6 line.
  • Individually pinned Kotlin and Scala driver artifacts are not changed by this Spring Data-specific recipe.
  • Driver-only modules that do not resolve Spring Data MongoDB are outside the recipe precondition.

Dependency behaviour covered

  • Explicit unmanaged Maven and Gradle dependencies are upgraded.
  • An explicitly imported MongoDB Driver BOM is upgraded while its managed components remain versionless.
  • Spring Boot-managed versionless dependencies remain unchanged.
  • Stale explicit versions that become redundant with Boot management are removed.
  • Explicit driver overrides are upgraded when Spring Data MongoDB is present transitively through a Boot starter.
  • Spring Data MongoDB and driver versions newer than the target lines are not downgraded.
  • Excluded Java, Kotlin, and Scala driver artifacts remain unchanged.

Tests

The clean rebased branch passed all of the following in GitHub Actions run 29866417761:

./gradlew recipeCsvValidateCompleteness --stacktrace

./gradlew test \
  --tests org.openrewrite.java.spring.data.MigrateSpringDataMongoDb5Test \
  --tests org.openrewrite.java.spring.data.UpgradeSpringData_4_0Test \
  --stacktrace

./gradlew --console=plain --info --stacktrace --warning-mode=all --no-daemon build

Test coverage includes Maven and Gradle dependencies, managed and unmanaged versions, MongoDB Driver BOM management, transitive Spring Boot starter use, compatible forward overrides, excluded artifacts, unrelated driver-only modules, and integration through UpgradeSpringData_4_0.

Metadata

recipeCsvGenerate added MigrateSpringDataMongoDb5 with a recipe count of 10 and updated UpgradeSpringData_4_0 from 21 to 31 composed recipes.

- Rename recipe to UpgradeSpringDataMongoDb_5_0 for naming consistency
- Drop extra spacing and comments from the MongoDB recipe list
- Return assertions directly via .actual() in the test lambdas
@timtebeek

Copy link
Copy Markdown
Member

It's not immediately clear to me how this relates to some of the newly opened issues:

Since we also already had

From our side we're fine to only have a single high over issue, with details only in the PR. That saves us from repeatedly triaging issues when the work is relatively straightforward.

@timtebeek timtebeek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the change here! I've applied a slight bit of polish, but we can merge once CI passes.

@github-project-automation github-project-automation Bot moved this from In Progress to Ready to Review in OpenRewrite Jul 22, 2026
@timtebeek
timtebeek merged commit 1868aee into openrewrite:main Jul 22, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from Ready to Review to Done in OpenRewrite Jul 22, 2026
@Kyran121

Copy link
Copy Markdown
Contributor Author

It's not immediately clear to me how this relates to some of the newly opened issues:

Since we also already had

From our side we're fine to only have a single high over issue, with details only in the PR. That saves us from repeatedly triaging issues when the work is relatively straightforward.

That makes sense. My intention was:

#1082 covered the dependency alignment implemented by this PR.
#1092 and #1093 captured the two follow-up areas deliberately left outside this PR: replacing the removed uber JARs and migrating legacy driver API usage.
#1091 is datastore-neutral and relates to the broader UpgradeSpringData_4_0 work rather than specifically to MongoDB.

I’m happy to simplify this. I can close #1091, #1092, and #1093, keep the MongoDB roadmap consolidated under #1081, and put the detailed scope for each future change in its implementation PR instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Spring Data MongoDB 5.0] Add migration composite and dependency alignment

2 participants