I have a Kotlin project where I'd like to have Kotlin warnings treated as errors. How can I do that?
问题:
回答1:
Since Kotlin 1.2, the command line argument -Werror
is supported. In Gradle, it's named allWarningsAsErrors
:
compileKotlin {
kotlinOptions.allWarningsAsErrors = true
}
回答2:
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.