Kotlin Academy · Lesson

Gradle Kotlin DSL

build.gradle.kts basics.

Lesson 1 of 413 steps

Gradle Kotlin DSL is a free Kotlin Academy lesson on CoddyKit. This is lesson 1 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the Kotlin Academy learning path, and your progress syncs across the web and the CoddyKit app. The Kotlin Academy course includes 4 lessons in total.

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, dependencies blocks
  • Type-safe extensions and .set() properties
  • settings.gradle.kts for project structure
  • Run tasks with ./gradlew

Next: dependencies and plugins in depth.

Free to start

Learn Kotlin with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
51
Lessons
203

Frequently Asked Questions

Is the “Gradle Kotlin DSL” lesson free?

Yes — any 3 lessons of the Kotlin Academy learning path, including “Gradle Kotlin DSL”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The Kotlin Academy course includes 4 lessons in total.

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, so you can start here or from the beginning and move at your own pace. This is lesson 1 of 4.

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

  1. Gradle Kotlin DSL
  2. Dependencies and Plugins
  3. Custom Tasks
  4. Version Catalogs
← Back to Kotlin Academy