如何取消特定的Kotlinc/Javac编译器警告? [英] How to suppress specific Kotlinc/Javac compiler warnings?

查看:139
本文介绍了如何取消特定的Kotlinc/Javac编译器警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何像JavaCompile一样抑制GradleKotlinCompiledeprecations in?

How to suppress deprecations in for KotlinCompile in Gradle similar to JavaCompile?

JavaCompile(有效):

tasks.withType(JavaCompile) {
    configure(options) {
        compilerArgs << '-Xlint:-deprecation'
    }
}

KotlinCompile(无效):

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
    kotlinOptions {
        freeCompilerArgs = ["-Xjavac-arguments=-Xlint:-deprecation"]
    }
}

参考:

类似的问题:

  • 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?

推荐答案

KotlinCompile任务上定义的kotlinOptions属性上似乎有一个suppressWarnings选项.将其设置为true可能会满足您的要求.

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.

这是您要执行的操作:

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
    kotlinOptions {
        suppressWarnings = true
    }
}

这篇关于如何取消特定的Kotlinc/Javac编译器警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆