Help migrating from Groovy to Kotlin

Hello Gradle experts!,

I want to migrate a complicated multi-module with and old Gradle version (4.7) to the latest Gradle. I would like to be able to test the new build environment by also moving to Kotlin (Existing version is Groovy). So my questions are:

  1. It is possible to have side by side Kotlin scripts with Gradle scripts, and let old Gradle use the Groovy scripts by default? ( I didn’t saw this approach documented here: Migrating build logic from Groovy to Kotlin)
  2. Or I should byte the bullet first by migrating from 4.7 to 7.2, while keep using Groovy? If so, any recommendations while doing this refactoring?

Thanks in advance, please let me know if you need me to explain this into more detail.

–Jose

Bite the bullet, update to 7.2, rename the scripts adding .kts, comment everything, leave only the rootProject.name = ".." in your settings.gradle.kts and sync.

Then uncomment step by step sync’ing everytime and checking that everything is fine till that

Thanks Giuseppe. I found out than renaming upgrading then renaming to kts works well. Lots of changes, but I like how the IDE is able to help me with auto-complete tasks better now.

1 Like