Skip to main content

Find which Java version is in use

org.openrewrite.java.migrate.search.AboutJavaVersion

A diagnostic for studying the distribution of Java language version levels (both source and target compatibility across files and source sets).

Recipe source

GitHub, Issue Tracker, Maven Central

This recipe is available under the Moderne Source Available License.

Options

TypeNameDescriptionExample
StringwhenUsesTypeOptional. Only mark the Java version when this type is in use.lombok.val

Example

Parameters
ParameterValue
whenUsesTypenull
Before
class Test {
}
After
/*~~(Java version: 11)~~>*/class Test {
}
Before
class Test2 {
}
After
/*~~(Java version: 11)~~>*/class Test2 {
}

Usage

This recipe has no required configuration options. It can be activated by adding a dependency on org.openrewrite.recipe:rewrite-migrate-java in your build file or by running a shell command (in which case no build changes are needed):

  1. Add the following to your build.gradle file:
build.gradle
plugins {
id("org.openrewrite.rewrite") version("7.5.0")
}

rewrite {
activeRecipe("org.openrewrite.java.migrate.search.AboutJavaVersion")
setExportDatatables(true)
}

repositories {
mavenCentral()
}

dependencies {
rewrite("org.openrewrite.recipe:rewrite-migrate-java:3.8.0")
}
  1. Run gradle rewriteRun to run the recipe.

See how this recipe works across multiple open-source repositories

Run this recipe on OSS repos at scale with the Moderne SaaS.

The community edition of the Moderne platform enables you to easily run recipes across thousands of open-source repositories.

Please contact Moderne for more information about safely running the recipes on your own codebase in a private SaaS.

Data Tables

Java versions by source set

org.openrewrite.java.migrate.table.JavaVersionPerSourceSet

A per-source set view of Java version in use.

Column NameDescription
Project nameThe module name (useful especially for multi-module repositories).
Source set nameThe source set, e.g. main or test.
Created byThe JDK release that was used to compile the source file.
VM vendorThe vendor of the JVM that was used to compile the source file.
Source compatibilityThe source compatibility of the source file.
Major version source compatibilityThe major version.
Target compatibilityThe target compatibility or --release version of the source file.

Contributors

Jonathan Schneider, Sam Snyder, Tim te Beek