Gradle - compileJava - remove compile Warnings

瘦欲@ 提交于 2019-11-30 23:00:59

问题


We use Gradle 2.1 and java plugin. During compileJava different warnings occur, for example:

warning: [options] bootstrap class path not set in conjunction with -source 1.7
Note: ../SomeClass.java uses or overrides a deprecated API.

We know what they mean but won't fix them (don't ask, other thread :) Is there a way to avoid these messages somehow? They disturb the output a lot:

:project1:compileJava
warning: [options] bootstrap class path not set in conjunction with -source 1.7
Note: SomeClass.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 warning
:project1:processResources
:project1:classes
:project1:jar
:project2:compileJava
warning: [options] bootstrap class path not set in conjunction with -source 1.7
1 warning
:project2:processResources
:project2:classes
:project2:jar
:project2:war

Isn't is possible for example to redirect the stderr stream during compileJava so that we can grep out the warnings? Or is there another way?


回答1:


try this:

tasks.withType(JavaCompile) {
    options.warnings = false
}



回答2:


Try adding:

options.compilerArgs += '-Xlint:-deprecation'



回答3:


No answer posted so far that currently works (Gradle 4.0.1), so here's what does work:

options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"


来源:https://stackoverflow.com/questions/28572602/gradle-compilejava-remove-compile-warnings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!