Hi David Weintraub,
Thanks very much for your reply.
Based on the approach you mentioned, i wrote total logic for the task. kindly
inspect once.
here, may i ask some questions. they are
1) In one <if> tag, i can write any no of <elseif> tags. is it write?
2) In one <if> tag, there should be only one <else> tag. is it write?
3) I should place below logic in a <target name="some-logic-tag">. is it write?
Actual Code is here.
=====================
<target name="some-logic-tag">
<if>
<equals arg1="${envv}" arg2="dev"/>
<then>
<if>
<equals arg1="${ssltype}" arg2="1ssl"/>
<then>
<copy.../>
</then>
<else>
<copy.../>
</else>
</if>
</then>
<elseif>
<equals arg1="${envv}" arg2="sit"/>
<then>
<if>
<equals arg1="${ssltype}" arg2="1ssl"/>
<then>
<copy.../>
</then>
<else>
<copy.../>
</else>
</if>
</then>
</elseif>
<elseif>
<equals arg1="${envv}" arg2="uat"/>
<then>
<if>
<equals arg1="${ssltype}" arg2="1ssl"/>
<then>
<copy.../>
</then>
<else>
<copy.../>
</else>
</if>
</then>
</elseif>
<elseif>
<equals arg1="${envv}" arg2="dev"/>
<then>
<if>
<equals arg1="${ssltype}" arg2="1ssl"/>
<then>
<copy.../>
</then>
<else>
<copy.../>
</else>
</if>
</then>
</elseif>
<else>
<echo message=" please provide proper values for 'envv' and 'ssltype'" />
</else>
</if>
</target>
Thanks & Regards,
vishy
-----Original Message-----
>From David Weintraub <[email protected]>
Sent Fri 7/17/2009 5:55 PM
To Ant Users List <[email protected]>
Subject Re: how to do conditional processing in ant
There are two general ways to do conditional processing. One is to use
the "if" or "unless" parameters on the task themselves:
<task name="copy">
<!-- Common Copying -->
<...>
<!-- Test Which Environment -->
<condition property="dev">
<equals arg1="${envv}" = "dev"/>
</condition>
<condition property="uat">
<equals arg1="${envv}" = "uat"/>
</condition>
<condition property="prod">
<equals arg1="${envv}" = "prod"/>
</condition>
<!-- Call Each Environment and Attempt an Execution -->
<antcall target="copy.dev"/>
<antcall target="copy.uat"/>
<antcall target="copy.prod"/>
</target>
<target name="copy.dev"
if="dev">
<...>
</target>
<target name="copy.uat"
if="uat">
<...>
</target>
<target name="copy.prod"
if="prod">
<...>
</target>
The above would execute the "correct" type of copying based upon the
value of the envv property.
If you use AntContrib
<http://ant-contrib.sourceforge.net/tasks/tasks/index.html>, you can
simplify the logic quite a bit:
<if>
<equals arg1="${envv}" arg2="dev"/>
<then>
<copy.../>
</then>
<elseif>
<equals arg1="${envv}" arg2="prod"/>
<then>
<copy .../>
</then>
</elseif>
<equals arg1="${envv}" arg2="uat"/>
<then>
<copy .../>
</then>
</elseif>
</if>
--
David Weintraub
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]