ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Urbano, Daniel" <durb...@grow.net>
Subject RE: taskdef and class loaders
Date Mon, 03 Mar 2003 20:01:25 GMT
Mike-

You might try using two separate build files, where the one building the
Java classes calls the other. So:

build_java_code.xml builds the Java code in question, then calls build.xml
which expects the code to exist.

Dano

-----Original Message-----
From: Mike McNally [mailto:m5@works.com] 
Sent: Monday, March 03, 2003 2:38 PM
To: Ant User
Subject: taskdef and class loaders

I've been setting up an ant build system for the first time, and
have run across a problem for which I *think* there may be some
provisions already.

The system being built contains code-generating tools, and then
subsequent layers that use those tools.  I'd like to wrap the
code generators in ant tags and I've been successful at doing
that, except for working out problems with the class loader.

Specifically, it seems that when my task code (i.e., my Java code
that extends the ant Task class) is loaded by a <taskdef tag to
define the new task, it's loaded by the system class loader if
my .class file is in the system classpath. If the system classpath
is empty, then the ant class loader loads the class.

Because my ant task depends on classes in a library that will
not be present when the target application runs, it's problematic
for me when the class is loaded via the system class loader, as
the task just does not work -- the library is not available to
the system classloader.  When the ant class loader loads my class,
then everything works, because all my libraries *are* available
on build.classpath.

Note that the above behavior happens regardless of the setting
of the "build.sysclasspath" property.  I have it set to "ignore",
but the system class loader is still used by <taskdef>.  I've
looked at the source code briefly but not enough to figure it
out.

I don't understand the "loaderID" parameter to <taskdef>, but
I wonder whether it might not be key to a solution.

I'm running ant 1.5.1 with JDK 1.3 if it matters.

--
[ you are my main foo ] Mike McNally -- m5@works.com

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

Mime
View raw message