ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Conor MacNeill <>
Subject override
Date Thu, 31 Jul 2003 12:07:59 GMT
I'd like to take a slightly different angle on the <import> issue by getting 
some thoughts on this little experimental task I wrote. I haven't cleaned it 
up at all (lots of unused imports, inner classes etc). Anyway it lets you 
override any target in the build. e.g. This build file

<project name="override" default="test">

  <taskdef name="override" 
  <taskdef name="super" 

  <override target="test">
    <echo message="pre"/>
    <echo message="post"/>

  <override target="test">
    <echo message="pre2"/>
    <echo message="post2"/>

  <target name="test">
    <echo message="test"/>


produces the following output
Buildfile: build.xml

     [echo] pre2
     [echo] pre
     [echo] test
     [echo] post
     [echo] post2



I think with a renaming <import> task this would let you override any part of 
the build easily.

BTW, note that simple renaming of targets is not enough. Any use of a target 
name needs to be updated too (e.g. <antcall>). Can be done (at time of use) 
but may require tasks knowing their import prefix. The import task will need 
this to do cascade renaming.

Anyway, just thought I'd throw it out there. Override might even be useful in 
an entity includes approach.



View raw message