How to recompile with -Xlint:deprecation

后端 未结 4 731
自闭症患者
自闭症患者 2020-12-13 13:15

I don\'t use Android Studio but I build everything from the command line using build.gradle. I generate a Lint report like this:

./gradlew lint
         


        
4条回答
  •  一整个雨季
    2020-12-13 13:45

    This is an accepted answer but solved this with Gradle Java plugin as below.
    Add java plugin to build.gradle file if not added already.

    plugins {
        // Apply the java plugin to add support for Java
        id "java"
    }
    

    Then add task compileJava and/or compileTestJava based on your need to check deprecations for only java main source code or java test source code.
    You can add various compile options as listed here

    compileTestJava {
       // options.incremental = true
       // options.fork = true
       // options.failOnError = false
        options.compilerArgs.add("-Xlint:deprecation")
    }
    

    Also, we can specify for the main and test sourcecode project as

    tasks.withType(JavaCompile) {
        options.compilerArgs.add("-Xlint:deprecation")
    }
    

提交回复
热议问题