Use Xlint:deprecation with android

后端 未结 5 2314
猫巷女王i
猫巷女王i 2021-02-19 10:57

So I almost always get some message like this when I\'m compiling my android app:

[javac] Note: /home/kurtis/sandbox/udj/androidApp/src/org/klnusbaum/udj/Playlis         


        
5条回答
  •  孤城傲影
    2021-02-19 11:45

    If you want to have a good CI + CD pipeline and you care about your code quality, a good option to show more information about lint complainings is by adding this to your top/root gradle.build:

    subprojects {
      gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
          options.compilerArgs += [
            '-Xlint:unchecked', // Shows information about unchecked or unsafe operations.
            '-Xlint:deprecation', // Shows information about deprecated members.
          ]
        }
      }
    }
    

    or

    subprojects {
      gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
          options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
        }
      }
    }
    

    If you only want to add one option (you would normally add more), inside the task JavaCompile you just need to add:

    options.compilerArgs << "-Xlint:unchecked"
    

    It's 2018 and you can rely on Gradle to set this up. I only added two compiler argument options but there are much more. You can find more information here and here.

提交回复
热议问题