How to recompile with -Xlint:unchecked in Ant build task?
Asked Answered
I

2

40

When I run the "compile" target of my Ant "build.xml" file, then I get the following message:

Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

My compile target is the following:

  <target name="compile">
    <javac srcdir="${src.dir}" destdir="${classes.dir}" debug="true" debuglevel="lines,source" includeantruntime="false">
      <classpath refid="class.path" />
    </javac>
    <javac srcdir="${test.dir}" destdir="${classes.dir}" debug="true" debuglevel="lines,source" includeantruntime="false">
      <classpath refid="class.path" />
    </javac>
  </target>

What do I have to change in my build.xml file so that -Xlint:unchecked is done there?

Impure answered 4/1, 2011 at 20:14 Comment(0)
R
68

Add the following element in <javac></javac> section:

<compilerarg value="-Xlint:unchecked" />
Rigger answered 4/1, 2011 at 21:21 Comment(4)
Yeah! This was helpful. Thanks. The compiler claims about the use of java.util.Vector and java.util.HashSet. Since they are obsolete I have to look for equivalent types. Any suggestions?Impure
@Benny: The uses of java.util.Vector should be replaced by java.util.List/java.list.ArrayListRigger
@Rigger Where should i given property in Build.gradle. I got the error in Android StudioThat
@NeetuShrivastava, did you find the way? If not, see my answer.Compressor
C
2

In AndroidStudio, do this:

allprojects {
    tasks.withType(JavaCompile) {
        options.compilerArgs << "-Xlint:deprecation"
    }
}
Compressor answered 20/8, 2015 at 23:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.