ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wannheden, Knut" <knut.wannhe...@paranor.ch>
Subject RE: polymorphism (was Re: antlib)
Date Fri, 25 Apr 2003 19:22:44 GMT
> I have been thinking about using namespaces with antlibs like this:
> 
> <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>
> 

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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message