You can use either Gradle or Maven to build your Kotlin project. You can create a new Kotlin project in Intellij IDEA without any build automation, but here is how to set up a Kotlin project for Gradle and Maven.
To use the Kotlin language with Gradle, first add the following buildscript { }
block to your build.gradle
file:
buildscript { ext.kotlin_version = '<version to use>' repositories { mavenCentral() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle- plugin:$kotlin_version" } }
Then, you will need to apply the plugin, as shown in the following code, as well as the directories that will hold the source code.
Note that src/main/kotlin
is already specified by default, but you would use the sourceSets { }
block to specify a different directory if needed:
apply plugin: "kotlin" sourceSets { main.kotlin.srcDirs += 'src/main/kotlin' }