问题
How to suppress deprecations
in for KotlinCompile
in Gradle
similar to JavaCompile
?
JavaCompile(works):
tasks.withType(JavaCompile) {
configure(options) {
compilerArgs << '-Xlint:-deprecation'
}
}
KotlinCompile(does not work):
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
kotlinOptions {
freeCompilerArgs = ["-Xjavac-arguments=-Xlint:-deprecation"]
}
}
References:
- https://kotlinlang.org/docs/reference/using-gradle.html#compiler-options
Similar questions:
- kotlin supress warning deprecated for android
- Mark unused parameters in Kotlin
- Kotlin: Suppress unused Property?
- How do I make the Kotlin compiler treat warnings as errors?
回答1:
It looks like there is a suppressWarnings
option on the kotlinOptions
property defined on the KotlinCompile
task. Setting that to true may do what you want.
This is how you would do that:
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
kotlinOptions {
suppressWarnings = true
}
}
来源:https://stackoverflow.com/questions/52488930/how-to-suppress-specific-kotlinc-javac-compiler-warnings