43

I'm a Android developer. As result I use Gradle for build android projects. I write (about 2 years) gradle scripts on Groovy. As result scripts is very compact, clear and easy to support. It is very good.

But in new version of Gradle is introduce new language - Kotlin.

My question is: What is the benefit (for writing Gradle scripts) if I switch from Groovy to Kotlin?

user7610
  • 25,267
  • 15
  • 124
  • 150
Alex
  • 1,857
  • 4
  • 17
  • 34
  • 3
    https://blog.gradle.org/kotlin-meets-gradle. – JB Nizet Jul 26 '17 at 19:54
  • 2
    beware that kotlin buildscript can be slow, both to build and to edit in IDE https://youtrack.jetbrains.com/issue/KT-24668 and https://youtrack.jetbrains.com/issue/KTIJ-14829 – user7610 Jul 28 '22 at 12:15

1 Answers1

44

Kotlin is statically typed, whereas Groovy is not. Statically typed languages like Kotlin enable IDEs to support particular tasks much better:

  • auto-completion and content assist
  • quick documentation
  • navigation to source
  • refactoring and more

This is a great advantage that Gradle sees and therefore started with Kotlin as an alternative to Groovy.

There are also some official statements which you can find here.

s1m0nw1
  • 76,759
  • 17
  • 167
  • 196
  • By Groovy I can generate (create dynamic) Gradle tasks (on fly).It's very powerfull mechanism. And it's ofnen help me. My question is: Is it possible on Kotlin? – Alex Jul 30 '17 at 13:08
  • 3
    Yes, you can https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:dynamic_tasks – Feedforward Dec 27 '18 at 14:07