You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Jacob, Anil - MWT" <Ja...@menlolog.com> on 2003/12/12 23:10:32 UTC
disabling targets dynamically
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
RE: disabling targets dynamically
Posted by "W. Sean Hennessy" <sh...@goldenhourdata.com>.
<!-- on windows systems ${env.COMPUTERNAME} is host name -->
<!-- target to evaluate which host -->
<target name="HostEvalA.tgt.nm">
<condition property="properties.isHostA">
<and>
<equals arg1=${env.COMPUTERNAME} arg2="HostA" />
${env.COMPUTERNAME} = "HostA"
</and>
</condition>
<condition property="properties.isHostB">
<and>
${env.COMPUTERNAME} = "HostB"
</and>
</condition>
</target>
<target name="HostEvalB.tgt.nm">
<condition property="properties.isHostA">
<and>
<equals arg1=${env.COMPUTERNAME} arg2="HostB" />
${env.COMPUTERNAME} = "HostA"
</and>
</condition>
</target>
<!-- use of unless to exclude if Host B -->
<target name="target2" depends=HostEvalB.tgt.nm" unless="properties.isHostB">
</target>
-----Original Message-----
From: Jacob, Anil - MWT [mailto:Jacob.Anil@menlolog.com]
Sent: Friday, December 12, 2003 2:11 PM
To: Ant Users (E-mail)
Subject: disabling targets dynamically
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
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: disabling targets dynamically
Posted by Antoine Lévy-Lambert <an...@antbuild.com>.
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
Re: disabling targets dynamically
Posted by Corey Jewett <cj...@syntheticplayground.com>.
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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org