rootstrap / android-base

Rootstrap Android Base project
https://rootstrap.com
40 stars 6 forks source link

Migrate Gradle Groovy (*.gradle) to Gradle Kotlin (*.gradle.kts) #61

Closed marcossalto closed 2 years ago

marcossalto commented 2 years ago

Description

In Android Studio, Gradle build scripts in our project structure use Groovy build language. We mainly define plugins, project settings and dependencies in our Gradle scripts. Writing code in these Gradle scripts doesn't seem excited since we're not very familiar with Groovy language. A Kotlin build script can contain any Kotlin language element.

Since most of us use Kotlin for development, it's easier and more flexible to have build scripts in Kotlin instead of Groovy. Kotlin DSL is based on the Kotlin core language. So the syntax is the same as the parent language, which gives us the benefit of using Kotlin for development. Kotlin DSL is fully compatible with Android Studio.

For that reason we find interesting migrating Groovy build scripts (.gradle) to Kotlin build scripts (.gradle.kts) for better reusability and easy maintenance


Tasks


Notes

We can list some benefits of choosing Kotlin DSL over Groovy

Gradle Dependencies Management

We use buildSrc + Kotlin DSL For more information, please visit Gradle Kotlin DSL Primer