On Tue, 23 Apr 2002 02:54, Nino Walker wrote: > Hi, > > I've been trying to use <typedef> to define type at runtime, but, it seems, > I can't declare an instance of the type. The type is registered w/ the > project, but Ant's UnknownElement barfs when it tries to handle the > <srcrule> tag.
Barfs how? throws an exception? > My build file looks something like this: > > <project> > ... > <typedef name="srcrule" classname="...SomeSrcRuleImpl"> > <classpath ... /> > </typedef> > > <srcrule id="my.srcrule" aproperty="value" /> > ... > <target> > <mytask> > <outputrule refId="my.srcrule" /> > </mytask> > </target> > > > Is there something patently wrong with this? It's not a classpath issue, > as the type is loaded... No, but it may be a classloader issue. When a <typedef> or <taskdef> is given a classpath, it creates a new classloader to load the class from. The problem is that they don't share this classloader with other <typedef> and <taskdef>'s that have the same classpath specified. Which means that <taskdef>'d tasks cannot use the <typedef>'d types by reference, because they're all in different classloaders. The types work fine when used as nested elements - it just when used by reference. What you should try is putting your custom tasks and types somewhere in ant's classpath, and then use <typedef> and <taskdef> without a classpath. -- Adam -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
