Apache ANT – javac classpath

Posted by batman on Feb 27th, 2010
2010
Feb 27

Have you ever wondered exactly what the classpath is you’re using when compiling your java classes using the ant task “javac”? Well, here’s a useful little addition that can easily be added to your ant builds. It’s really no rocket science, but just provides a “visual” listing of the contents of the classpath.

<target depends="_setup" name="_compile" />
      <pathconvert property="echo.path.compile" pathsep="${line.separator}| |--" refid="project.class.path"></pathconvert>

      <echo message="|-- compile classpath" />
      <echo message="| |" />
      <echo message="| |-- ${echo.path.compile}" />

      <javac debug="${compile.debug}" srcdir="src" target="1.5" destdir="build" source="1.5">
             <classpath refid="project.class.path" />
      </javac>
</target>

Output similar to the following can be expected:

init:
compile:
|-- compile classpath
|   |
|   |-- /home/bruce/projects/quartz/lib/activation.jar
|   |-- /home/bruce/projects/quartz/lib/log4j.jar
|   |-- /home/bruce/projects/quartz/lib/mail.jar
|   |-- /home/bruce/projects/quartz/lib/commons-cli-1.1.jar
|   |-- /home/bruce/projects/quartz/lib/commons-configuration-1.5.jar
|   |-- /home/bruce/projects/quartz/lib/commons-dbutils-1.1.jar
|   |-- /home/bruce/projects/quartz/lib/commons-dbcp-1.2.2.jar
|   |-- /home/bruce/projects/quartz/lib/commons-pool-1.3.jar
|   |-- /home/bruce/projects/quartz/lib/commons-io-1.3.2.jar
|   |-- /home/bruce/projects/quartz/lib/commons-lang-2.3.jar

Powered by Zoundry Raven

Technorati :
Del.icio.us :
Zooomr :
Flickr :

Share and Enjoy:
  • Facebook
  • Twitter
  • Digg
  • StumbleUpon
  • del.icio.us
  • Yahoo! Buzz
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • laaik.it
  • Google Buzz
  • Technorati
  • Slashdot
  • Reddit

Leave a Comment




XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.