Class UpgradeJava

java.lang.Object
org.openrewrite.Recipe
org.axonframework.migration.UpgradeJava
All Implemented Interfaces:
Cloneable

public class UpgradeJava extends org.openrewrite.Recipe
Bumps the Java compiler target to a configurable LTS, with validation that the target satisfies the Axon Framework 5 minimum (Java 21).

Wraps UpgradeJavaVersion to:

  • expose a single, well-named entrypoint with a sensible default (21, the Axon Framework 5 minimum). Projects already on a later Java release (23, 24, 25, …) are left untouched — UpgradeJavaVersion only upgrades, never downgrades — so the default is conservative on purpose;
  • reject targets below 21 so misconfigurations fail loudly rather than producing a build that cannot compile against Axon 5.

This recipe only updates build files (pom.xml, build.gradle); it does not apply any source-level Java modernizations. If you also want source rewrites such as text blocks, pattern matching, sequenced collections or javaxjakarta translation, run the upstream org.openrewrite.java.migrate.UpgradeToJava21 separately or compose it into your own wrapping recipe.

The targetVersion option is overridable per invocation — see the module README.md for instructions on raising the target above the default (e.g. Java 25).

Since:
5.1.1
Author:
Mateusz Nowak
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.openrewrite.Recipe

    org.openrewrite.Recipe.Builder, org.openrewrite.Recipe.DelegatingRecipe
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Default target Java version when targetVersion is unset.
    static final int
    Minimum supported target.

    Fields inherited from class org.openrewrite.Recipe

    contributors, examples, PANIC
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    UpgradeJava(@Nullable Integer targetVersion)
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
     
    List<org.openrewrite.Recipe>
     
    @Nullable Integer
     

    Methods inherited from class org.openrewrite.Recipe

    addDataTable, builder, buildRecipeList, causesAnotherCycle, clone, createRecipeDescriptor, equals, getContributors, getDataTableDescriptors, getDescriptor, getEstimatedEffortPerOccurrence, getExamples, getInstanceName, getInstanceNameSuffix, getJacksonPolymorphicTypeTag, getMaintainers, getName, getTags, getVisitor, hashCode, maxCycles, noop, onComplete, run, run, run, setContributors, setExamples, validate, validate, validateAll, validateAll, withOptions

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_TARGET_VERSION

      public static final int DEFAULT_TARGET_VERSION
      Default target Java version when targetVersion is unset. Equal to the Axon Framework 5 minimum (Java 21). Chosen so that projects already on a higher Java release are left untouched, since UpgradeJavaVersion only upgrades and never downgrades.
      See Also:
    • MINIMUM_TARGET_VERSION

      public static final int MINIMUM_TARGET_VERSION
      Minimum supported target. Axon Framework 5 requires Java 21+; lower targets are rejected at configuration time.
      See Also:
  • Constructor Details

    • UpgradeJava

      public UpgradeJava()
    • UpgradeJava

      public UpgradeJava(@Nullable Integer targetVersion)
  • Method Details

    • getTargetVersion

      public @Nullable Integer getTargetVersion()
    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in class org.openrewrite.Recipe
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in class org.openrewrite.Recipe
    • getRecipeList

      public List<org.openrewrite.Recipe> getRecipeList()
      Overrides:
      getRecipeList in class org.openrewrite.Recipe