tags:

views:

23

answers:

2

Hello,

Possibly one of those really terrible beginner questions where the manual will tell you everything, but, anyway, take this line below:

ant -Dfoo=bar buildme

in my build script, what is the parameter, variable to pick up "buildme"?

Regards

Steve

A: 

Not sure I understand your question, but "buildme" is the target to execute, not a property.

ant [options] [target [target2 [target3] ...]]

You "pick it" by creating the corresponding target:

<target name="buildme">
  <!-- tasks that will execute here -->
</target>

As for the foo property, you "pick it" by using ${foo}.

Miguel Fonseca
Hi Miguel, basically, I want to be able to retrieve the target parameters in my build script. I would expect something like ${target} to work, but unfortunately not.
Steve Griff
Oh... There's an old thread in ant says you can't do it =S http://markmail.org/message/rjgp2gm54kxnnqih
Miguel Fonseca
Thanks for the link Miguel, it looks like it's not possible. I only wanted the target parameter for a very minor reason. No problem. Thanks for your time. Steve.
Steve Griff
As a last resource you can always set a property inside each target with it's name =D
Miguel Fonseca
A: 

The list of targets invoked is available in the property

ant.project.invoked-targets

If there is a default target specified, then that will be the invoked target. If one or more targets are specified on the command line, these appear comma-separated in the property. Note that the property only becomes set once execution passes to a target - if you try to read the property outside of any target, it will be unset.

So, if the project has a default target 'zero':

$ ant one two
# ant.project.invoked-targets is set to:
one,two

and

$ ant
# ant.project.invoked-targets is set to (default):
zero
martin clayton