Wannheden, Knut wrote:

>> <project>
>>    <.. init properies .../>
>>    <use xmlns:antcontrib="antlib:${ant-contrib.jar}"
>>             xmlns:antelope="antlib:${antelope.jar}">
>> 
>> <target name="test">
>>            <antelope:if>
>>                  ....
>>            </antelope:if>
>>            <antcontrib:foreach ...>
>>         </target>
>>     </use>
>> 
>> </project>


Or even:
  <antelope:if xmlns:antelope="antlib:${ant-contrib.jar}" />


In any case - if ComponentHelper is used, it'll get
"antlib:/path/to/ant-contrib.jar" as first param and if as the second param
- and any helper in the chain can create the task.

I don't like passing the .jar very much - but that's probably the only 
way if we want to use META-INF/antlib.xml.

The alternative would be to use /net/sf/antcontrib/antlib.xml (i.e.
descriptor in a package ), and use "antlib:net.sf.antcontrib" as namespace.
Then getResource() can be used, and we don't have to worry about 
multiple jars providing META-INF/antlib.xml - which forces us to use the 
.jar file directly.


Costin



>> 
> 
> That is almost the same thing as I had in mind.  Although I've been
> thinking about some slight variations to this, where no top-level element
> like <use/>
> would be necessary.  The Jelly style would be:
> 
> <project xmlns:antcontrib="antlib:${ant-contrib.jar}"
>          xmlns:antelope="antlib:${antelope.jar}">
>    <.. init properies .../>
> 
>    <target name="test">
>         <antelope:if>
>               ....
>         </antelope:if>
>         <antcontrib:foreach ...>
>    </target>
> 
> </project>
> 
> Here <target/> is still toplevel and the antlibs are loaded on project
> initialization (or on demand).  But I'm not sure I like this automagical
> loading.  Something inbetween would be this:
> 
> <project>
>    <.. init properies .../>
>    <use resource="${ant-contrib.jar}" ns="antlib:ant-contrib"/>
>    <use resource="${antelope.jar}" ns="antlib:antelope"/>
> 
>    <target name="test" xmlns:antcontrib="antlib:ant-contrib"
>                        xmlns:antelope="antlib:antelope">
>       <antelope:if>
>           ....
>       </antelope:if>
>       <antcontrib:foreach ...>
>    </target>
> 
> </project>
> 
> which is slightly more verbose, but cleaner IMO.  Especially since the
> antlib loading is explicit.
> 
> --
> knut


Reply via email to