ANT task to call another task based on input -


i have written ant task automated deployment.

    <target name="deploywmbcomponent">     <for list="${esb.ci.wmb.deployment.target.brokers}" param="brokername" delimiter=" ">         <sequential>                            <for list="${esb.ci.wmb.deployment.target.egs}" param="egname" delimiter=" ">                   <sequential>                             <exec executable="cmd.exe" failonerror="true" logerror="true" append="true" vmlauncher="false" dir="${esb.ci.wmb.dp.home}">                         <arg value="/c" />                         <arg value="mqsiprofile.cmd &amp;&amp; mqsideployscript.bat" />                         <arg value="-n" />                         <arg value="${brokerconfigfilepath}\@{brokername}.broker" />                         <arg value="-e" />                         <arg value="@{egname}" />                         <arg value="-w" />                         <arg value="600" />                         <arg value="-a" />                         <arg value="${barlocalpath}" />                                                                              </exec>                 </sequential>             </for>         </sequential>     </for>       </target> 

all properties defined in property file. i'm adding new boolean parameter, default_propagation, if true above mentioned script should call ant task, if false above script should execute directly.

first i'll answer question: you'll want (assuming you're using ant > 1.8) add if , unless both targets , have 1 depend on other.

<target name="deploywmbcomponent" if="${default.propogation}" depends="other-thing"> 

when add new target

<target name="other-thing" unless="${default.propogation}"> 

a working example:

<project name="foo" default="default-deploy">    <target name="default-deploy" if="${default.propogation}" depends="other-deploy">     <echo message="default" />   </target>    <target name="other-deploy" unless="${default.propogation}">     <echo message="other" />   </target>  </project> 

call with: ant -ddefault.propogation=false , ant -ddefault.propogation=true

see ant docs on if , unless complete rundown. thing think on, right have default , other thing. it's there third. boolean won't enough.

having said - trying do? how non-default propagation different? different server names (properties)? why not call either 1 target or other when run build? when feel need conditionals , loops in ant, sign shouldn't doing you're doing in ant.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -