ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Deragon <>
Subject Self written ant task does not get the CLASSPATH passed to ant with -lib option
Date Tue, 25 Aug 2009 17:12:56 GMT

Moving ant scripts from Eclipse to a standalone system, I found out that
my own written Ant task does not get the full CLASSPATH passed to ant with
the -lib option.

  ant \
   -lib /somepath \
   -lib /somepath/ \
   -lib /usr/java5/lib \
   -lib /usr/java5/jre/lib \
   -lib /usr/java5/jre/lib/ext \
   -lib /usr/java5/jre/lib/security \

My ant task tries to load the file that is the
CLASSPATH, using the following code:

  InputStream resourceAsStream =

This fails.  When I check for the CLASSPATH my ant task gets from ant, it

  export-import.xml:151: '' file not found in
CLASSPATH:  /application/cwf/apache-ant-1.7.1/lib/ant-launcher.jar

I obtain the CLASSPATH using the code:

  ClassLoader sysClassLoader = ClassLoader.getSystemClassLoader();
  URL[] urls = ((URLClassLoader) sysClassLoader).getURLs();

The urls variable contains all the paths found in the CLASSPATH and from
it, the task prints the values and the error message shown above.

As you notice, the CLASSPATH passed to my own ant task only contains
ant-launcher.jar.  Curiously, ant.core.lib only contains that jar.

Why the paths passed to ant with -lib are not found in the CLASSPATH?  How
can I fix this?  I do not have this problem when running my ant scripts
from within Eclipse.

Please accept my apologies if this is a frequently asked question;  I am
sure I am not the first user who has hit this problem.  Strange thing, I
could not find on the web any reference to such a problem.  I guess a
poor choice of keywords from my part...

Best regards,
Hans Deragon
Consultant en informatique/Software Consultant
Deragon Informatique inc.        Open source (contribution):

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message