Configuring Ant To Use javac's -Xlint:unchecked Option

| No TrackBacks
Here's a quick Java tip.  If you're using ant, and you want the java compiler (javac) to share more information about various compilation warnings, you can integrate javac's -Xlint:unchecked option into your build script.

During your compilations, you might see warnings like this:

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

To pass the -Xlint:unchecked option to javac within ant, user the compilerarg element like so:

<javac srcdir="${src.dir}"
       destdir="${classes.dir}"
       classpathref="libraries">
  <compilerarg value="-Xlint"/>
</javac>

For more granular control over the compiler warning output (-Xlint:unchecked, -Xlint:serial, etc.), see the Non-Standard Options section of the javac man-page.  If you want a real-world example, check out the Gagawa build script on Google Code.

Did You Find this Helpful?

Did you find this post helpful, or at least, interesting?

  

About Mark

A Silicon Valley native, Mark Kolich is a full-time Software Engineer and a consultant for hire. A web technologies expert, his current focus is on building powerful and robust cloud-driven web-applications using Java, PHP, Perl, AJAX, DHTML, CSS, and JavaScript. His favorite programming languages are PHP, Java and JavaScript. He uses Linux, enjoys biking to work, loves building great software, and always writes elegant, readable, and maintainable code.

No TrackBacks

No trackbacks attached to this entry.

Twitter (@markkolich)

Translate

About this Entry

This page contains a single entry by Mark Kolich published on April 10, 2009 10:18 PM.

HOWTO: Use Apache mod_deflate To Compress Web Content (Accept-Encoding: gzip) was the previous entry in this blog.

Prevent Google From Caching Your Site (Meta tags: googlebot and robots) is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.