ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: check property
Date Thu, 28 Apr 2005 08:52:46 GMT
On Thu, 28 Apr 2005, Mikael Petterson <mikael.petterson@ericsson.com>
wrote:

> In my ant build.xml I have a property called:
> 
> <property name="xsl.file" value="interface.xsl"/>
> 
> This can be changed when I run my build.xml ( from -Dxml.file) when
> starting ant.
> 
> How can I check the value of 'xsl.file' and depending on the value
> give another poperty ('pkg') a value

> if xsl.file = interface.xsl --> pkg = /se/company/app/interface
> if xsl.file = enumeration.xsl --> pkg= /se/company/app/interface

note that your values for pkg are the same ;-)

<condition property="pkg" value="second-line">
  <equals arg1="enumeration.xsl" arg2="${xsl.file}"/>
</condition>
<property name="pkg" value="first-line"/>

You could use a second condition, but since your first line is your
default, you can as well use a default for pkg.

This is the general pattern of conditional properties in Ant, set your
default value last.

Both <condition> and <property> will no override an existing property
and <condition> won't even evaluate the condition if it finds the
property has already been set.

Stefan

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


Mime
View raw message