Ace8 is the modernization practice of AceMQ.24/7 support from AceMQ after go-live
Book an Assessment

Tutorial

OpenRewrite with Maven and Gradle: dry run, run, review.

A working setup for the build plugin, the recipe BOM, the Java 21 and Spring Boot 3 recipes, and the habit that keeps you safe: read the patch first.

AceMQ engineering team4 min readEngineer-reviewed

The short answer

To use OpenRewrite, add the rewrite-maven-plugin or the org.openrewrite.rewrite Gradle plugin, name your recipe with rewrite.activeRecipes, add the recipe module as a dependency, run dryRun to produce a patch, read it, then run the recipe for real. Commit the result on a branch and run your tests.

On this page

  • Java
  • Spring Boot
  • OpenRewrite
  • Gradle
  • Jakarta EE
  • Maven
  • Java
  • Spring Boot
  • OpenRewrite
  • Gradle
  • Jakarta EE
  • Maven

Before you start

What you need first

For what recipes do and where they stop, read OpenRewrite recipes for Java 21 and Spring Boot 3.

  • A Git branch with a clean working tree, so the recipe diff is the sole change.
  • A build that compiles and passes tests today. If it does not, fix that first; you cannot tell recipe damage from old damage.
  • A JDK that can run the plugin. The plugin runs on the JDK your build uses, so the target JDK may need to be installed separately.

Maven

Set up the OpenRewrite Maven plugin

You can skip editing the pom for a one-off try. Pass everything on the command line: mvn -U org.openrewrite.maven:rewrite-maven-plugin:dryRun -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-migrate-java:RELEASE -Drewrite.activeRecipes=org.openrewrite.java.migrate.UpgradeToJava21. Swap dryRun for run to apply it. RELEASE floats to the latest version, so use it for a trial, not a repeatable run.

Pin the plugin and module versions in the pom for any run you want to repeat. A moving version changes the recipe, and a recipe that changes between runs is no longer reproducible.

Step 01 of 05

Add the plugin

In pom.xml, under build/plugins, add groupId org.openrewrite.maven, artifactId rewrite-maven-plugin, with a pinned version.

Planning this for your estate? Get a fixed scope and price first.

Gradle

Set up the OpenRewrite Gradle plugin

Task and file names are as of the current plugin documentation. Check the OpenRewrite docs for the version you use.

Step 01 of 05

Apply the plugin

In build.gradle.kts: id("org.openrewrite.rewrite") version "<latest>". Look up the current version on the Gradle plugin portal.

Versions

Why the recipe BOM matters

Recipe modules depend on each other and on the core engine. If you pin each module by hand, versions drift apart and you get odd errors. The rewrite-recipe-bom (org.openrewrite.recipe:rewrite-recipe-bom) is a bill of materials that fixes compatible versions together.

In Maven, import it in dependencyManagement as a pom with scope import, then add recipe modules without versions. In Gradle, add rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:<version>")) and omit versions on the module lines. Update the BOM version as one change, and review the recipe diff again.

Recipes

Run the Java 21 and Spring Boot 3 recipes

Two recipes cover most of the mechanical upgrade work. Names change between releases, so confirm them in the current recipe catalogue. The Spring Boot recipes are versioned (3_0, 3_1, 3_2, 3_3 and so on); pick the target minor version you want.

Run one recipe at a time on a Java 8 or 11 application: first the Java upgrade, build and test, then Spring Boot 3, build and test again. Spring Boot 3 requires Java 17 or later, so the order matters. Several recipes in one run give you one large diff and no way to tell which one broke the build.

See Spring Boot 3 migration and javax to jakarta for what the recipes leave behind.

GoalRecipeModule
Java 21 migrationorg.openrewrite.java.migrate.UpgradeToJava21rewrite-migrate-java
Spring Boot 3.3org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3rewrite-spring
javax to jakartaorg.openrewrite.java.migrate.jakarta.JavaxMigrationToJakartarewrite-migrate-java

Review

How to review the diff

  • Read the patch from dryRun before you run anything. Check that it touches the files you expect and nothing more.
  • After run, use git diff and look for changes to build files, properties and resource files, not just Java.
  • Compile, then run the full test suite. Record failures; do not hide them with edits to the tests.
  • Look for comment markers or TODO text a recipe may leave where it could not decide.
  • Check behavior the tests do not cover: serialization formats, date handling, security configuration, startup flags.
  • Commit the recipe output as its own commit, separate from your manual fixes, so a reviewer can see what the tool did.

Next step

How Ace8 helps

Ace8 is the AI-assisted application modernization practice of AceMQ. We run these recipes first, then AI-assisted tools on what remains, then tests and engineer review. We are running the recipes above on an open-source Java 8, Spring Boot 2 and javax application and will publish the run log, including failures, on the OpenRewrite page. For a client estate, the assessment tells you which applications suit this approach.

FAQ

Frequently asked questions

Something else on your mind? Ask an engineer.

dryRun computes the changes and writes a patch file without touching your source. run applies the changes to your files. Always do dryRun first.

Start here

Know the cost before anything moves.

A fixed-price assessment gives you the inventory, the risk score and a phased plan. Scope and cost are fixed before the migration starts.

  • InventoryEvery application, its stack and what it depends on.
  • Risk scoreWhere a change is likely to break, ranked.
  • Phased planWhat moves first, which tools lead, and the fixed price.

Get in touch

Talk to a modernization engineer

Tell us what you run today. An engineer, not a sales script, replies within one business day.

305-204-2607info@ace8.io

66 W. Flagler St. 9th Floor
Miami, FL 33130

What are you moving off? *

Fixed price. Scope and cost before any migration starts.