You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Nino Walker <ni...@xtime.com> on 2002/04/22 18:54:03 UTC

Runtime defined datatypes help.

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.

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...  

Help is greatly appreciated,

Thanks,

Nino

Re: Runtime defined datatypes help.

Posted by Adam Murdoch <ad...@apache.org>.
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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Runtime defined datatypes help.

Posted by Stefan Bodewig <bo...@apache.org>.
On Mon, 22 Apr 2002, Nino Walker <ni...@xtime.com> wrote:

> I've been trying to use <typedef> to define type at runtime, but, it
> seems, I can't declare an instance of the type.

This is a known bug in 1.4.x that should be fixed using 1.5alpha and
certainly in the upcoming beta release.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Runtime defined datatypes help.

Posted by Steve Loughran <st...@iseran.com>.
----- Original Message -----
From: "Nino Walker" <ni...@xtime.com>
To: <an...@jakarta.apache.org>
Sent: Monday, April 22, 2002 9:54 AM
Subject: Runtime defined datatypes help.


> 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.
>
> 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...

try using it inside a target, rather than outside...I think you need to be
running ant1.5 to use a new datatype outside a target


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>