Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle - compileJava - remove compile Warnings

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?

like image 777
Marcel Avatar asked Feb 17 '15 22:02

Marcel


3 Answers

try this:

tasks.withType(JavaCompile) {
    options.warnings = false
}
like image 179
Rene Groeschke Avatar answered Nov 08 '22 00:11

Rene Groeschke


Try adding:

options.compilerArgs += '-Xlint:-deprecation'
like image 40
cmcginty Avatar answered Nov 08 '22 01:11

cmcginty


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

options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
like image 42
Abhijit Sarkar Avatar answered Nov 08 '22 00:11

Abhijit Sarkar