How to set Kotlin source encoding in Gradle?

Viewed 3427

When building Java or Groovy using Gradle, it's possible to define source encoding like this:

compileJava {
    options.encoding = 'UTF-8'
}

compileTestJava {
    options.encoding = 'UTF-8'
}

compileGroovy {
    groovyOptions.encoding = 'UTF-8'
}

compileTestGroovy {
    groovyOptions.encoding = 'UTF-8'
}

However, similar approach with Kotlin doesn't work:

compileKotlin {        
    kotlinOptions.jvmTarget = '1.8'
    kotlinOptions.encoding = 'UTF-8'
}

It fails with the error:

* What went wrong:
A problem occurred evaluating root project 'backend'.
> No such property: encoding for class: org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptionsImpl

I actually can't find any info about Kotlin compiler's encoding at all. Does it mean that there is no such option? What charset does it use then, UTF-8, system default (I hope not)?

1 Answers
Related