You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Oran Fry <or...@cs.waikato.ac.nz> on 2008/07/25 01:21:41 UTC

Target Addressing in Ant

Hello List,

I have added a feature to Ant that I call Target Addressing, to help us 
make releases of our open source project (greenstone). I want to know if 
it's worth tidying up my changes and checking them back into Ant itself. 
Having this feature has made my life a lot easier in developing and 
running huge Ant projects, and I want others to benefit too.

Target Addressing is a feature which gives each target in a target tree 
an address like 1 or 1.3.2 . These addresses can be specified on the 
command line to gain better control over exactly which targets are 
executed. You can give Ant an address to start execution from, an 
address to stop execution at, and/or an address of a target to descend down.

A project like:
<project default="main">
    <target name="main">
       <antcall target="compile"/>
       <antcall target="create-distribution"/>
    </target>
    <target name="compile">
       <antcall target="checkout-code"/>
       <antcall target="set-version-number-property"/>
    </target>
    <target name="create-distribution">
       <antcall target="delete-unneeded-code"/>
    </target>
</project>

Would get a target tree like:
1 compile
    1.1 checkout-code
    1.2 set-version-number-property
2 create-distribution
     2.1 delete-unneeded code

And you could run things like:
ant -from 1.2  (runs 1.2,  2,  2.1)
ant -to 2.1  (runs 1,  1.1,  1.2,  2)
ant -descend 1  (runs 1,  1.1,  1.2)
ant -from 1.1 -to 1.2  (runs 1.1)

And if you ever need to see the addresses of each target in the tree, 
you can use a simulation flag, which walks the tree and prints out the 
addresses and target names without actually executing anything:
ant -sim

- The addresses are computed at runtime, with the main target (the the 
project default or the one specified on the command line) getting a null 
address.
- Any combination of the options outlined can be used, including none at 
all (in which case Ant just behaves as normal).
- The -from argument is inclusive in nature, while the -to argument is 
exclusive - I have an explanation as to why I think this is the most 
appropriate and intuitive implementation which I can present if needed.
- Another flag to Ant to explicitly turn Target Addressing on (something 
like -ta), might be a good idea too.
- If needed, addresses could be hidden from the user and target names 
could be used instead with the number addresses used in the background. 
This would be a bit more computationally expensive though.

So before I start figuring out how to check in the changes, I just want 
to make sure that there is nothing like this in Ant already, and also 
that people actually want this feature. If there are any questions, 
please ask.

Kind Regards,
Oran Fry.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org