ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eugene Kirpichov" <>
Subject Ant profiler + Embedded ant classpath problems
Date Thu, 27 Mar 2008 08:19:13 GMT
Hi everybody,

1. I have written a line-level profiler for ant build scripts: . I was surprised at how easy it
was and at the fact that no one has done that before (at least, to my
best knowledge)

2. I was going to add a feature to launch ant script directly from the
GUI but I ran into problems with supplying extra classpath to ant. Is
there a working example (sized less than, say, 3kloc code) of doing
that or a troubleshooting guide for that?
There was a letter to this mailing list today about just embedding ant
in the application - I did that successfully, no big deal. However I
found no API in Project etc. like 'addClasspathElement()' and started
to play with classloaders.
First, I did the same thing as what is done in I changed the system property
'java.classpath' and did Thread.currentThread().setContextClassLoader
with an URLClassLoader packed up with the extra classpath. That just
plain didn't work; ant didn't use that classloader for loading the
extra classes.
Then I tried to use AntClassLoader in the same way and launched the
build in a separate thread; that didn't work either, with a different
message but same meaning.
My suspection was that for loading the extra classpath Ant for some
reason uses not the classloader I gave him but Class.forName() or
Then I tried to create a Project object not with new Project() but
with that extra classloader and had to write a lot of things like
In this case, I had class incompatibility problems between this
Project and objects I passed to  its methods (which I still created
manually). I didn't dare do _everything_ with the extra loader.

I did 3 or 4 more different attemts and finally gave up.

Well, the description above is rather lengthy and I unfortunately
didn't keep copies of all my attempts' sources to show you, so it may
be better if just someone told me 'To programmatically add extra
classpath to a project, do this and that' :)

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

View raw message