简体   繁体   English

使用Gradle在Groovy项目构建中抑制Java警告“Unsafe is internal proprietary API”

[英]Suppress Java warning “Unsafe is internal proprietary API” in Groovy project build with Gradle

I've have a Groovy project built with Gradle (1.8) in which some Java classes report the following compiler warning message: 我有一个使用Gradle(1.8)构建的Groovy项目,其中一些Java类报告以下编译器警告消息:

warning: Unsafe is internal proprietary API and may be removed in a future release
import sun.misc.Unsafe;

Is there a way to suppress that error message? 有没有办法抑制该错误消息? I've found some answers suggesting to use the javac compiler option -XDignore.symbol.file but I'm unable to apply it in the Gradle build when using the Groovy plugin. 我发现一些答案建议使用javac编译器选项-XDignore.symbol.file但是在使用Groovy插件时我无法在Gradle构建中应用它。

Any solution ? 有解决方案吗

Thanks 谢谢

Add following to your gradle.build file 将以下内容添加到gradle.build文件中

compileJava {
    options.compilerArgs << '-XDignore.symbol.file'
    options.fork = true // may not needed on 1.8
    options.forkOptions.executable = 'javac' // may not needed on 1.8
}

fork is required on gradle 1.6, not sure about 1.8 update: it's still required on 1.8 在gradle 1.6上需要fork,不确定1.8更新:它仍然需要1.8

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM