4.3.3. Configuring Support for Kotlin

If you create a new project in Studio, it allows you to select the preferred language (Java, Kotlin, Java+Groovy) on the first page of the project creation wizard, so the build scripts will be configured accordingly.

If you want to add support for Kotlin to an existing project, make the following changes in the build.gradle file:

buildscript {
    ext.cubaVersion = '7.2.0'
    ext.kotlinVersion = '1.3.61' // add this line
    // ...
    dependencies {
        classpath "com.haulmont.gradle:cuba-plugin:$cubaVersion"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" // add this line
        classpath "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"   // add this line
    }
}
// ...
apply(plugin: 'cuba')
apply(plugin: 'org.jetbrains.kotlin.jvm') // add this line
// ...
configure([globalModule, coreModule, webModule]) {
    // ...
    apply(plugin: 'cuba')
    apply(plugin: 'org.jetbrains.kotlin.jvm') // add this line

    dependencies {
        compile("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion") // add this line
        compile("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion") // add this line
// ...

If the project has Kotlin or Groovy support configured, you can choose in what language Studio will generate code. See Settings/Preferences > Languages & Frameworks > CUBA > Project settings > Scaffolding language.