0

While compiling using Ant, my Java application gives more than 1000 warnings (mainly deprecated API related as this is a legacy code) and it is very difficult to find error message(s) mixed up with thousands of warnings messaged in the log.

I tried suppressing the warnings by passing arguments in Ant javac task, but didn't work.

Is there any options to separate warnings and errors in the log, like all warnings first and then errors?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Abhilash
  • 792
  • 2
  • 7
  • 17

1 Answers1

1

The warnings are displayed by javac, Ant is just forwarding them into the console. Ant cannot distinguish them between javac warnings and errors. But you can configure javac warning output. You can use the attribute 'nowarn' in the javac tasks.

<javac nowarn='on' .... />

You can also select exactly which warning you let to suppress. You have then to look into the javac documentation (look at the Xlint options), and use the 'compilerarg' element of the javac task.

<javac .... >
    <compilerarg line="-Xlint:-deprecation"/>
</javac>
Nicolas Lalevée
  • 2,014
  • 1
  • 15
  • 14
  • I am getting warnings because of using sun.* package which is deprecated. will not suppress such warnings. Ref http://stackoverflow.com/questions/13855700/suppress-javac-warning?rq=1 – Abhilash Jul 26 '13 at 05:14
  • Is it possible to pipe the output of javac in to another ant task to seperate the warnings? Are there any existing tasks to reuse? – Abhilash Jul 26 '13 at 05:15
  • 1
    You could use the `exec` task to launch javac manually and then use the `outputproperty` to capture the output. Then with a `loadresource` resource task, a `property` resource and a filterchain, something may be working. But this will be quite heuristic and very error prone. I wouldn't recommend that. – Nicolas Lalevée Jul 26 '13 at 09:56