Scrivio Interview library
ConceptFoundations7 min read · updated 12 November 2026

Why have many teams moved Gradle builds from Groovy DSL to Kotlin DSL, and what are the costs?

Teams move to the Kotlin DSL because it is statically typed: the IDE knows what every name in the script means, so we get real completion, navigation into Gradle and plugin sources, and errors when the script is compiled instead of strange failures at run time. Gradle generates type-safe accessors for the plugins applied in the plugins block, and recent Gradle versions use Kotlin DSL by default for new builds. The costs are slower first-time script compilation and some rewriting of dynamic Groovy idioms, though both DSLs can coexist during a migration.

Why this question is asked

Build scripts are code that every developer touches, often without knowing Gradle well. With the Groovy DSL, a typo in a property name or a block in the wrong place may only show up as a confusing error at configuration time, or not at all. The Kotlin DSL changes that experience, and it has become the default for new projects. Interviewers ask this to see whether we understand what static typing gives a build script and whether we can weigh the real costs instead of following a trend. In this answer, we will recap the two DSLs, see what static typing buys us, look at type-safe accessors, then go through the costs and how a gradual migration works.

1A Quick Recap of the Two DSLs

A DSL, a domain-specific language, is a way of writing code that reads like configuration. Gradle has two: the original Groovy DSL in build.gradle files and the Kotlin DSL in build.gradle.kts files. Both call the same Gradle API underneath and can express the same builds. What differs is the language and, most importantly, how much the tools know about the script before it runs.

Groovy is a dynamic language. When the script says test { useJUnitPlatform() }, Groovy works out at run time what test refers to. Kotlin is statically typed: the compiler must know, when it compiles the script, that test is a Test task and that useJUnitPlatform is a method on it. Everything else in this answer follows from that difference.

Java
// build.gradle (Groovy)
plugins { id 'java' }
java { toolchain { languageVersion = JavaLanguageVersion.of(25) } }
test { useJUnitPlatform() }
ext.springVersion = '6.2.1'
// build.gradle.kts (Kotlin)
plugins { java }
java { toolchain { languageVersion = JavaLanguageVersion.of(25) } }
tasks.test { useJUnitPlatform() }
val springVersion by extra("6.2.1")

Notice how similar they look. The differences are small: double quotes for strings, parentheses for function calls, tasks.test instead of a bare test, and extra properties declared explicitly. The similarity is why migration is usually mechanical for simple scripts.

2What Static Typing Gives Us

Because the IDE knows the type of every expression, IntelliJ IDEA can complete names inside java { } with exactly the properties of the java extension, jump into the source of a Gradle or plugin class with one click, and show documentation on hover. With Groovy, completion is best effort, because the IDE often cannot know what a name means until the script runs.

Errors move earlier, too. A misspelled property is a compile error with a line number.

Java
tasks.test {
useJunitPlatform() // compile error: Unresolved reference 'useJunitPlatform'
maxParallelForks = "4" // compile error: type mismatch, Int expected
}
// The same mistakes in Groovy fail only when the script runs, with
// Could not find method useJunitPlatform() ... or, for some properties, not at all

So the Kotlin DSL turns a class of debugging sessions into red underlines in the editor. For people who touch build scripts only occasionally, this is the biggest benefit.

3Type-Safe Accessors for Plugins

When we apply plugins in the plugins { } block, Gradle knows which plugins a script uses before running the rest of it. It then generates Kotlin accessors for what those plugins add: extensions such as java and checkstyle, configurations such as implementation and testRuntimeOnly, and tasks such as tasks.test. That is why we can write implementation("...") as if it were a built-in function.

There is a catch. These accessors exist only for plugins applied in the plugins block of that script. If a plugin is applied in another way, such as apply(plugin = "java") or from a parent project, the accessors are not generated and we must fall back to string-based calls.

Java
plugins { `java-library` }
dependencies {
implementation("com.google.guava:guava:33.4.0-jre") // generated accessor
}
// If the plugin was applied with apply(plugin = "java-library") instead:
dependencies {
"implementation"("com.google.guava:guava:33.4.0-jre") // string form needed
}
tasks.named<Test>("test") { useJUnitPlatform() } // instead of tasks.test

4The Costs

The first cost is speed of script compilation. Kotlin scripts are compiled, and the first time a script is compiled, or after it changes, it takes noticeably longer than Groovy, often a few seconds per script in a large build. Gradle caches the compiled scripts, so unchanged scripts cost nothing on later builds, and the configuration cache can skip configuration entirely. Still, someone editing the root script or buildSrc will feel it.

The second cost is rewriting dynamic Groovy idioms. Groovy lets us add ext properties anywhere and read them as if they were fields, reach any project property by name, configure tasks by bare name, and use closures freely. In Kotlin each of these needs an explicit form: extra properties through by extra, project properties through findProperty or providers.gradleProperty, tasks through tasks.named, and some old plugins with Groovy-centric APIs need extra casting. Scripts full of such idioms take real work to convert.

The smaller costs are learning a new syntax, IDE memory use for script models in large builds, and occasional rough edges in older third-party plugins. Since Gradle 8.2, plain = assignment works for lazy Property types, which removed one of the most common annoyances, set(...) everywhere.

Groovy DSL and Kotlin DSL side by side
AspectGroovy DSLKotlin DSL
TypingDynamic, resolved when runStatic, checked when compiled
IDE completion and navigationBest effortAccurate, into Gradle sources
Errors in scriptsFound at configuration timeFound at compile time
First compile of a changed scriptFasterSlower, then cached
Dynamic idioms (ext, bare names)NaturalNeed explicit forms
Default for gradle initNo longerYes, in recent Gradle versions

5Migrating Gradually

We do not have to convert a whole build at once. Each subproject's script is independent, so a build can have build.gradle in some projects and build.gradle.kts in others, and a Kotlin script can still apply a Groovy script plugin with apply(from = "legacy.gradle"). A sensible order is settings.gradle.kts first, then convention plugins, where typing helps the most, then project scripts one at a time, running the build after each.

Two practical tips help. Move from apply(plugin = ...) to the plugins block first, even in Groovy, because that is what unlocks accessors later. And replace ext properties with a version catalog, which both DSLs can use, so the hardest dynamic idiom disappears before the conversion.

6Follow-up questions

Is the Kotlin DSL slower for every build?

No. The extra cost is in compiling scripts, which happens only when a script or its classpath changes. Gradle caches compiled scripts, and with the configuration cache an unchanged build skips the configuration phase entirely. Day to day, most builds feel the same; the cost shows up when editing build logic or running a cold build on a fresh CI agent.

Why do accessors fail inside allprojects or subprojects blocks?

Accessors are generated from the plugins a script applies in its own plugins block. Inside allprojects { } in the root script, Gradle cannot know which plugins each project will have, so names such as implementation or java are not available as accessors. This is one more reason to replace cross-project blocks with convention plugins, where the plugins block is known.

Can Groovy and Kotlin scripts share version information?

Yes. A version catalog in gradle/libs.versions.toml is available to both as libs, and so are plugins and extensions. Sharing values through ext is possible but awkward from Kotlin, which is another reason to move such values into the catalog during migration.

7Conclusion

In this answer, we saw that the Kotlin DSL calls the same Gradle API as the Groovy DSL but is statically typed, so IDEs offer accurate completion and navigation and mistakes become compile errors. Gradle generates type-safe accessors for plugins applied in the plugins block, and recent Gradle versions make Kotlin the default for new builds. The costs are slower first compilation of changed scripts and rewriting dynamic Groovy idioms such as ext properties and bare task names, and a gradual migration is possible because both kinds of script can live in one build.

What to say in the interviewAbout 90 seconds aloud

Open with

The main reason is static typing. The Groovy DSL is dynamic, so the IDE often cannot know what a name in the script means until it runs, and a typo shows up as a confusing error at configuration time.

Then, if they want more

The Kotlin DSL is compiled, so IntelliJ gives accurate completion, lets me jump into Gradle and plugin sources, and a misspelled method or a wrong type is a compile error with a line number. Gradle also generates type-safe accessors for the plugins applied in the plugins block, which is why implementation, java or tasks.test work like normal Kotlin functions.

And Gradle itself now uses Kotlin DSL as the default for new builds, so documentation and examples lean that way. The costs are real but manageable. Compiling a Kotlin script the first time, or after a change, is slower than Groovy; it is cached afterwards, so it mostly hurts when someone edits build logic or on cold CI agents.

Dynamic Groovy habits like ext properties, reading project properties by bare name, or configuring tasks by name need explicit Kotlin forms, and accessors are missing if plugins are applied with apply or from allprojects blocks.

I would migrate gradually, since Groovy and Kotlin scripts can coexist: settings and convention plugins first, move values into a version catalog, then project scripts one by one.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Gradle user manual
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Why have many teams moved Gradle builds from Groovy DSL to Kotlin DSL, and what are the...": https://scrivio-interview-library.netlify.app/java/gradle/644e7520c5/