You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Horvath Adam <ar...@gmail.com> on 2009/07/09 08:31:35 UTC
test if exists
Hi!
I'm learning ant.
ant -Dpropname=xxx // correct usage
ant // incorrect usage of my build
Can I test a property existence?
if propname not exists (
echo "Give more command line arg"
exit ant running
)
Thanks, Adam
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: test if exists
Posted by Henk van Voorthuijsen <vo...@xs4all.nl>.
On Thu, 2009-07-09 at 10:13 +0200, Horvath Adam wrote:
> > <fail>
> > Give more command line arg
> > <condition>
> > <isset property="propname"/>
> > </condition>
> > </fail>
An even simpler way would be:
<fail unless="propname"/>
See the documentation: http://ant.apache.org/manual/CoreTasks/fail.html
Henk
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: test if exists
Posted by Horvath Adam <ar...@gmail.com>.
> <fail>
> Give more command line arg
> <condition>
> <isset property="propname"/>
> </condition>
> </fail>
Thanks a lot.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
AW: test if exists
Posted by Ja...@rzf.fin-nrw.de.
>ant -Dpropname=xxx // correct usage
>ant // incorrect usage of my build
>
>Can I test a property existence?
>
>if propname not exists (
> echo "Give more command line arg"
> exit ant running
>)
You could check that with the <isset> condition.
In that case you would combine it with fail:
<fail>
Give more command line arg
<condition>
<isset property="propname"/>
</condition>
</fail>
If you can work with default values you can easily set that:
<property name="propname" value="defaultvalue"/>
Because Ant properties are immutable (once set they cant be changed)
Ant will use the user value (from the command line) if given, otherwise
the default.
For an introduction have a look at the tutorial
http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html
Jan
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org