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
qazw...@gmail.com

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

Reply via email to