OpenRewrite

OpenRewrite is a code remediation tool. Unlike other tools that only detect issues, OpenRewrite can automatically fix them by rewriting source code.

Specs Using OpenRewrite

Spec Description Severity Remediation Recipe
MIG-001 Upgrade to Java 17 major UpgradeToJava17
MIG-002 Replace java.util.Date with java.time major UseJava8TimeClasses
MIG-003 Spring Boot 3 Migration major UpgradeSpringBoot_3_2

Quick Start

Maven

<plugin>
    <groupId>org.openrewrite.recipe</groupId>
    <artifactId>rewrite-maven-plugin</artifactId>
    <version>5.20.0</version>
    <configuration>
        <activeRecipes>
            <recipe>org.openrewrite.java.migrate.UpgradeToJava17</recipe>
        </activeRecipes>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.openrewrite.recipe</groupId>
            <artifactId>rewrite-migrate-java</artifactId>
            <version>2.12.0</version>
        </dependency>
    </dependencies>
</plugin>

Usage

# Dry-run (see what would change)
mvn rewrite:dryRun

# Apply all configured recipes
mvn rewrite:run

# Apply a specific recipe
mvn rewrite:run -DactiveRecipe=org.openrewrite.java.migrate.UpgradeToJava17

Config Location

openrewrite.yml

Trigger Policy

Runs as a dry-run before releases only. Developers can apply recipes locally when needed.

Guides

Guides for this tool will be added as the project evolves.