Kotlin/Gradle/JUnit starter project
Just a quick tutorial to start a blank new Kotlin project using Gradle. Optionally, JUnit can also be added.
1. Create a project
- Download and install IntelliJ Community, free for Java/Kotlin projects. Alternatively, you can use IntelliJ Ultimate EAP (no subscription required).
- Go to “File” ⇀ “New project”.
- Activate “Create Git repository”.
- Pick “Kotlin” as language.
- Pick “Gradle” as the build system.
- Pick “Kotlin” as Gradle DSL. Since we’re using Kotlin, it makes sense that the Gradle DSL is Kotlin.
- Fill in the remaining details, and press “Create”.

2. Setup Git
To ensure you don’t lose your work and can always go back in time, ensure you set up Git — even if only locally.
- Start a new git repository (
git init
) if you haven’t picked “Create Git repository” before. - Create a
.gitignore
file with the following content, and commit all the changes:
/.gradle
/.idea
/build
3. Update Gradle/Kotlin
The IDE doesn’t use the latest versions of Gradle and Kotlin, so we need to do it manually.
- Check the latest version of Gradle (e.g.
7.4.2
) and update the filegradle/wrapper/gradle-wrapper.properties
accordingly. - Check the latest version of Kotlin (e.g.
1.6.21
) and update the filebuild.gradle.kts
accordingly.
plugins {
kotlin("jvm") version "1.6.21". // or 1.+ for always latest
}
4. Set up JUnit
- At
build.gradle.kts
’s dependencies, set up JUnit 5:
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:5.+")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.+")
}tasks.withType<Test> {
useJUnitPlatform()
}
2. Create a dummy test (src/test/kotlin/DummyTest.kt
) and run it just to prove that the JUnit setup is good:
class TestAmazonCart {
@Test
fun `everything is fine`() {
assertTrue(true)
}
}

You can also run the tests with ./gradlew test