Skip to content

Upgrade imported Spring Boot 3 BOMs in UpgradeToJava25 - #1402

Open
bryanfriedman wants to merge 1 commit into
openrewrite:mainfrom
bryanfriedman:java25-spring-boot-bom
Open

bryanfriedman wants to merge 1 commit into
openrewrite:mainfrom
bryanfriedman:java25-spring-boot-bom

Conversation

@bryanfriedman

Copy link
Copy Markdown

What's changed

Adds org.openrewrite.java.migrate.UpgradeSpringBootBomForJava25 and includes it in UpgradePluginsForJava25 (so in UpgradeToJava25), right after UpgradeSpringBootParentForJava25.

It is the BOM counterpart of the parent recipe. When a Maven project imports spring-boot-dependencies or spring-boot-starter-parent 3.x with <scope>import</scope> instead of inheriting from it, the imported BOM is moved to the latest 3.5 release. Boot 2 and Boot 4 BOMs are left alone, same as the parent recipe.

Why

On a project that imports Boot as a BOM, UpgradeToJava25 leaves Boot on its old release. That causes three problems:

  • Boot's managed Lombok (1.18.34 in Boot 3.3) can't compile on Java 25.
  • Boot's managed Byte Buddy (1.14.x) breaks every Mockito mock on Java 25. The UpgradeDependencyVersion steps for Byte Buddy and Mockito don't override managed versions.
  • spring-boot-maven-plugin usually shares the BOM's version property, and at 3.3.x it fails repackage with "Unsupported class file major version 69". UpgradePluginVersion skips it because the property is shared.

Moving the BOM to 3.5.x fixes all three through the one version property.

This was found on techa03/goodsKill during a Moderne self-paced eval run. That repo imports spring-boot-starter-parent 3.3.3 through ${springboot.version}. Reproducing the build there took about ten minutes of hand fixes after UpgradeToJava25.

Testing

  • New UpgradeSpringBootBomForJava25Test covers both imported BOM artifacts through a version property, inclusion in UpgradeToJava25, and no change for Boot 2.7 and 4.0.
  • I couldn't run Gradle locally: this environment's Code Genome credentials get a 401, and rewrite-* 8.93.11 isn't on Maven Central. Please rely on CI for the test run.
  • I ran the recipe definition through the Moderne CLI against techa03/goodsKill. It changed <springboot.version>3.3.3</springboot.version> to 3.5.16 and nothing else.

Not covered

EnableLombokAnnotationProcessor still skips a root POM that configures maven-compiler-plugin but declares Lombok only in child modules (its ModuleHasDependency precondition). On JDK 23+ that leaves annotation processing off. That is a separate fix.

Projects that import spring-boot-dependencies or spring-boot-starter-parent
with scope import, rather than inheriting from the parent, were left on
their old Boot release by UpgradeToJava25. Boot's managed Lombok, Byte Buddy
and Mockito then stay too old for Java 25, and a spring-boot-maven-plugin
sharing the BOM's version property fails to repackage Java 25 classes.

Add UpgradeSpringBootBomForJava25, the BOM counterpart of
UpgradeSpringBootParentForJava25: it moves an imported Boot 3.x BOM to the
latest 3.5 release and leaves Boot 2 and Boot 4 alone.

Seen on techa03/goodsKill, which imports spring-boot-starter-parent 3.3.3
through a springboot.version property.
Comment on lines +474 to +475
artifactId: spring-boot-*
version: 3.x

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.

Should we limit this to just 3.5.x ? Because there's often required changes going between two or more minor versions.

Suggested change
artifactId: spring-boot-*
version: 3.x
artifactId: spring-boot-*
version: 3.5.x

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

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants