ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antoine Lévy-Lambert <anto...@antbuild.com>
Subject Re: disabling targets dynamically
Date Fri, 12 Dec 2003 22:57:19 GMT
Note that the if and unless attributes of the target tag do not work on 
the value of a property, but simply check whether the property is defined.
In a typical pure ant scenario, you need a target init where you are 
going to set a property on.hosta if you are on hosta and on.hostb if you 
are on hostb

<target name="init">
    <!-- find out on which host you are, may be with the HOSTNAME 
command -->
    <exec  executable="hostname" outputproperty="myhost"/>
    <condition property="on.hosta">
        <equals arg1="${myhost}" arg2="HostA"/>
    </condition>
    <condition property="on.hostaorb">
      <or>
        <equals arg1="${myhost}" arg2="HostA"/>
        <equals arg1="${myhost}" arg2="HostB"/>
    </or>
    </condition>
</target>
<target name="target1" if="on.hostaorb" depends="init">
    <!-- do something --->
</target>

<target name="target2" if="on.hostaorb" depends="init">
    <!-- do something --->
</target>

<target name="target3" if="on.hosta" depends="init">
    <!-- do something --->
</target>

There are also if tasks in antelope and ant-contrib which you can use too.


Antoine


Corey Jewett wrote:

> target has unless and if attributes that should let you do this.
>
> http://ant.apache.org/manual/using.html#targets
>
> Corey
>
>
> On Friday, December 12, 2003, at 02:10 PM, Jacob, Anil - MWT wrote:
>
>>
>>  Is there a way to disable a target at runtime based on certain value 
>> from a property
>>
>>  For example If I have - target 1, target 2, target 3 all of the are 
>> available when I run ant on HostA, where as when I run on Host B I 
>> want only target1 and target to be available.
>>
>> Is this possible?
>> Anil
>>



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


Mime
View raw message