Gradle Kotlin DSL
build.gradle.kts basics.
Gradle Kotlin DSL is a free Kotlin Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Kotlin Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What is the Gradle Kotlin DSL?
Gradle build scripts can be written in Groovy (build.gradle) or Kotlin (build.gradle.kts). The Kotlin DSL gives you type safety and IDE autocomplete.
Why .kts?
Benefits of the Kotlin DSL:
- Compile-time checking of the build script
- Autocomplete and navigation in the IDE
- Same language as your app code
The tradeoff is slightly slower first-time script compilation.
The plugins Block
The plugins { } block applies Gradle plugins. This is where you enable Kotlin, application packaging, etc.
plugins {
kotlin("jvm") version "2.0.0"
application
}Group and Version
Define project coordinates at the top level. These become part of the published artifact identity.
group = "com.example"
version = "1.0.0"The repositories Block
Declare where Gradle downloads dependencies. mavenCentral() is the most common.
repositories {
mavenCentral()
google()
}The dependencies Block
List your dependencies by configuration. Kotlin DSL uses function calls with string coordinates.
dependencies {
implementation("com.google.guava:guava:33.2.1-jre")
testImplementation(kotlin("test"))
}Configuring Extensions
Plugins add typed extensions. With the application plugin you set the main class via the application { } block.
application {
mainClass.set("com.example.MainKt")
}Setting Properties
Many DSL values are Property objects, set with .set(...). Newer Gradle also supports assignment with =.
tasks.jar {
archiveBaseName.set("my-app")
}settings.gradle.kts
The settings.gradle.kts file names the project and includes submodules in a multi-module build.
rootProject.name = "my-app"
include(":core", ":app")Running Tasks
Invoke tasks from the command line with the Gradle wrapper.
// ./gradlew build
// ./gradlew run
// ./gradlew test
// ./gradlew tasks (list available tasks)Groovy vs Kotlin DSL
Key syntax differences:
- Strings use double quotes in Kotlin (single in Groovy)
- Method calls use parentheses
- Properties use
.set()or=instead of space-assignment
Quick Check
Which file uses the Gradle Kotlin DSL?
Recap
You learned the Kotlin DSL basics:
plugins,repositories,dependenciesblocks- Type-safe extensions and
.set()properties settings.gradle.ktsfor project structure- Run tasks with
./gradlew
Next: dependencies and plugins in depth.
Frequently asked questions
Is the “Gradle Kotlin DSL” lesson free?
Yes — the full text of “Gradle Kotlin DSL” is free to read here on the web, and the Kotlin Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Kotlin Academy course, upgrade to CoddyKit PRO.
What will I learn in “Gradle Kotlin DSL”?
build.gradle.kts basics. You practise Kotlin Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Kotlin Academy?
No prior experience is required. Kotlin Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Gradle Kotlin DSL” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Kotlin Academy lesson?
Yes. Every Kotlin Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Gradle Kotlin DSL
- Dependencies and Plugins
- Custom Tasks
- Version Catalogs