You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Marco Struck <M....@PopNet.de> on 2000/12/12 09:08:45 UTC

check of properties

hi folk,

i would like to ensure that a property has been set - what is the rigtht way
?

	<!-- call with: ant param -Dparam=test -->
	<target name="param">
		<!-- ensuring that param has been set -->
		<echo message="param=${param}" />
	</target>


Re: check of properties

Posted by Stefan Schmitt <ss...@raleigh.ibm.com>.
Hi

use the if/unless attribute of  <target> so you can create two targets where
one is accessed if the property is set and the other is accessed if the
property is not set. Like the following hack

<project name="Hugo" default="param_available" basedir=".">
    <target name="param_available" if="param" depends="param_notavailable">
        <echo message="param set value=${param}"/>
    </target>
    <target name="param_notavailable" unless="param">
        <echo message="param notset"/>
    </target>
</project>

This xml syntax should make the following output
if param is set -> param set value=  xxx
and if not -> param is not set

Yours
Stefan S
----- Original Message -----
From: "Marco Struck" <M....@PopNet.de>
To: <an...@jakarta.apache.org>
Sent: Tuesday, December 12, 2000 9:08 AM
Subject: check of properties


> hi folk,
>
> i would like to ensure that a property has been set - what is the rigtht
way
> ?
>
> <!-- call with: ant param -Dparam=test -->
> <target name="param">
> <!-- ensuring that param has been set -->
> <echo message="param=${param}" />
> </target>
>
>