ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Deragon <h...@deragon.biz>
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
Greetings.

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/ant.personal.properties \
   -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 ant.personal.properties file that is the
CLASSPATH, using the following code:

  InputStream resourceAsStream =
      ClassLoader.getSystemClassLoader().getResourceAsStream(
          "ant.personal.properties");

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

  export-import.xml:151: 'ant.personal.properties' 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.
http://www.deragon.biz        Open source (contribution):
mailto://hans@deragon.biz     http://autopoweroff.sourceforge.net


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message