How do I make the Kotlin compiler treat warnings as errors?

This does not appear to be currently available in the Kotlin command-line help, or arguments available to the Kotlin compiler:

K2JVMCompilerArguments.java

and

CommonCompilerArguments.java

But some people in Gradle do things like this to scan logging of the compiler to know when a warning was generated. How to fail gradle build on Javadoc warnings

Within the IDE Plugins available for Kotlin (Intellij IDEA and Eclipse) there is no such option.

You should file a feature request (or check if one already exists) in YouTrack which has all the issue tracking for the Kotlin project. And if you do so, please post the issue here so it can be tracked.


Since Kotlin 1.2, the command line argument -Werror is supported. In Gradle, it's named allWarningsAsErrors:

compileKotlin {
    kotlinOptions.allWarningsAsErrors = true
}

Tags:

Kotlin