# Setting Up a Kotlin Project — Kotlin

Source: https://www.skillbyai.com/en/kotlin/f-setup

> IntelliJ IDEA, Gradle and the command-line compiler.

## Tools you will use

**IntelliJ IDEA** (by JetBrains) and **Android Studio** (built on it) have the best Kotlin support. Most projects build with **Gradle**, and the Gradle **Kotlin DSL** (`build.gradle.kts`) lets you write build scripts in Kotlin with IDE completion. Maven is also supported. For quick experiments you can use the command-line compiler `kotlinc`, Kotlin scratch files in the IDE, or the online Kotlin Playground. Plugin and library versions change often, so check the docs for your version.

## A minimal Gradle Kotlin DSL build

build.gradle.kts for a JVM application (versions are examples).

```kotlin
plugins {
    kotlin("jvm") version "2.0.21"   // check the docs for the current version
    application
}

repositories {
    mavenCentral()
}

dependencies {
    testImplementation(kotlin("test"))
}

kotlin {
    jvmToolchain(17)
}

application {
    mainClass.set("MainKt")   // top-level main in Main.kt compiles to class MainKt
}
```

## Use the Gradle wrapper

Commit `gradlew` and the wrapper files so every developer and CI machine uses the same Gradle version; run `./gradlew run` or `./gradlew test` instead of a globally installed Gradle.

**Quiz:** What is `build.gradle.kts`?

- [x] A Gradle build script written in the Kotlin DSL
- [ ] A compiled Kotlin library
- [ ] An Android manifest
- [ ] A ktlint configuration file

*Answer:* A Gradle build script written in the Kotlin DSL. The .kts extension means a Kotlin script.
