Recompile with -Xlint parameters

I’m having these warnings when building:

Note: Some input files use or override a deprecated API. 
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

I just want to know how to recompile with these parameters (-Xlint:deprecation and -Xlint:unchecked), even if it is warning I don’t want to supress it, but get the details.

Thanks in advance.

1 Like

You need to configure your JavaCompile tasks with those extra arguments. If you want this for all JavaCompile tasks rather than just particular ones, you can do this:

tasks.withType(JavaCompile) {
    options.compilerArgs << '-Xlint:unchecked'
    options.deprecation = true

The CompileOptions on the JavaCompile tasks has a deprecation property you can configure directly and not worry about actual command line argument, but you can add both -Xlint:deprecation and -Xlint:unchecked as compilerArgs, if you want.


Awesome, it works.

Thank you.

Hello, I’m having this exact same issue. Where do I insert the line of code that you shared? Should I be looking for a JavaComplie file? Or is this something you add to or some other file related to the program installation.

For some extra info, I’m using gradle to build the newest version of Picard, but I keep getting the same warnings above. The build finishes “successfully” but when I run the tests, I get a failed test.

@sjfleck The code snippet is typically added to a build.gradle file in your project. This can be the project root build.gradle file or build.gradle file of one of your project’s modules.
You can add it to the root level inside that file - it does not need to be nested inside another code element.

is there a way to set it on command line without changing build.gradle.kts?

You could write an init script that sets the parameter and specify that init script via -I parameter when invoking Gradle or putting it to your <GRADLE_USER_HOME>/init.d/.

Example content of a verbose-compile.init.gradle.kts:

allprojects {
    tasks.withType<JavaCompile>().configureEach {
        options.isDeprecation = true
1 Like