ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Derek Baum <derek.b...@paremus.com>
Subject ivy settings classpath always creates new classloader when used with subant
Date Thu, 16 Oct 2008 14:51:08 GMT
Hi,

I have a custom Ivy resolver that keeps a static cache because it is 
time-consuming to initialise.

However, this cache doesn't work in a multi-project build, because the 
ivysettings/classpath command is creating a new URLClassLoader for each 
subant iteration, so all static class fields are reset.

<ivysettings>

  <classpath file="${ivy.settings.dir}/sigil-ivy-plugin.jar" />

  <typedef name="sigil" classname="org.cauldron.bld.ivy.SigilResolver" />

  ...

</ivysettings>


I'm building multiple projects, using ivy:buildlist and subant, as in 
the Ivy multi-project example.

Each iteration of subant, causes IvySettings to reload.
IvySettings.classloader is thus null and so a new URLClassLoader is created.

I temporarily worked around this by loading my plugin at the same time 
as Ivy (i.e. not using settings/classpath), but I'd really like the 
setting/classpath method to work too.

One possible solution would be to add a "loaderRef" attribute to 
settings/classpath, similar to the Ant taskdef/typedef tasks, to make it 
use the same ClassLoader.

Alternatively, IvySettings could simply be changed to only create a new 
URLClassLoader if the list of URLs  has changed. I attach a simple patch 
to IvySettings.java that does this and seems to work OK.

If this is valid and useful, let me know and I'll raise it in Jira.

Thanks,

Derek














Mime
View raw message