[Bjonnh.net]# _

Create a Kotlin project in Idea using File->New->Project

The window that appears when creating a new project

The second window that appears when creating a new project

It may ask you to open in a new window or the existing one.

Immediately create a Git repository VCS->Import Into Version Control->Create Git Repository (create in current directory)

I then usually right click on the “src” directory, and do Mark directory -> Unmark as source directory

And create a src/main/kotlin hierarchy then mark the kotlin one as a source directory. This allows to mix different languages more easily.

Make sure you have gradle installed.

And run:

gradle wrapper --gradle-version 4.5

Create a file build.gradle.kts (you will need a recent version of Idea for that to work well >=2018.1) with the following content

You will at some point get a warning in the status bar, asking you to import the Gradle project, do it.

import org.jetbrains.kotlin.gradle.dsl.Coroutines
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

val mainclass = "yourpackage.MainKt"
val version = "0.0.1"

plugins {
    val kotlin_version = "1.2.30"
    application
    kotlin("jvm") version kotlin_version
    id("com.github.johnrengelman.shadow") version "2.0.2"
}

application {
    mainClassName = mainclass
}

dependencies {
    compile(kotlin("stdlib"))
}

repositories {
    jcenter()
}

tasks.withType<Jar> {
    manifest {
        attributes(mapOf(
                "Main-Class" to mainclass
        ))
    }
}

That way, you can do a gradle clean build and get a fat-jar that works. Just run it with java -jar build/libs/projectname-all.jar

I tried many solutions that the authors said worked and none was working properly, I hope this one is going to work for more than one person…