← All recipes
Open source

Update Gradle project Java compatibility

Recipe IDorg.openrewrite.gradle.UpdateJavaCompatibility
Artifactorg.openrewrite:rewrite-gradle

Find and updates the Java compatibility for the Gradle project.

Single recipeApache 2.0

Usage

You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe org.openrewrite.gradle.UpdateJavaCompatibility --recipe-option "version=11"

If the recipe isn’t available locally, install it with:

mod config recipes jar install org.openrewrite:rewrite-gradle:8.88.0

Options

NameTypeDescription
versionrequiredIntegerThe Java version to upgrade to.
e.g. 11
compatibilityTypeCompatibilityTypeThe compatibility type to change
declarationStyleDeclarationStyleThe desired style to write the new version as when being written to the sourceCompatibility or targetCompatibility variables. Default, match current source style. (ex. Enum: JavaVersion.VERSION_11, Number: 11, or String: "11")
allowDowngradeBooleanAllow downgrading the Java version.
addIfMissingBooleanAdds the specified compatibility type if one is not found.

Data tables

Structured output this recipe can produce.

  • Source files that had resultsSource files that were modified by the recipe run.org.openrewrite.table.SourcesFileResults
  • Source files that had search resultsSearch results that were found during the recipe run.org.openrewrite.table.SearchResults
  • Source files that errored on a recipeThe details of all errors produced by a recipe run.org.openrewrite.table.SourcesFileErrors
  • Recipe performanceStatistics used in analyzing the performance of recipes.org.openrewrite.table.RecipeRunStats