Migrate to Kotlin 2.x

Proprietary

Modernizes a Kotlin 1.x codebase for Kotlin 2.x: replaces stdlib APIs deprecated between 1.4 and 2.0 with their modern equivalents, swaps JVM-only java.lang/java.util helpers for multiplatform Kotlin extensions, migrates inline class to @JvmInline value class, and removes @OptIn annotations for experimental markers that have since graduated to stable.

org.openrewrite.kotlin.migrate.Kotlin1To2$KtRecipe
mod run . --recipe='org.openrewrite.kotlin.migrate.Kotlin1To2$KtRecipe'

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Use modern Kotlin stdlib idioms
  2. Use kotlin.math instead of java.lang.Math
  3. Use Kotlin number extensions instead of java.lang.Integer/Long/Double/Float/Boolean
  4. Use Char extensions instead of java.lang.Character
  5. Use Kotlin collection extensions instead of java.util.Collections
  6. Use Kotlin array extensions instead of java.util.Arrays
  7. Use kotlin.text.Regex instead of java.util.regex.Pattern
  8. Use @JvmInline value class instead of inline class
  9. Remove redundant @OptIn annotations