如果是蚂蚁脚本的话

jer*_*han 2 xml ant

嗨当前我有这个蚂蚁脚本:

        <target name="Cleanup Snapshots" description="Cleanup TrueCM snapshots">
        <echo>Executing: ${TrueCM_App}\ssremove.exe  -h${TrueCM_Host} "${TrueCM_New_SS}"</echo>
        <exec executable="${TrueCM_App}\ssremove.exe"   failonerror="${TrueCM_Failon_Exec}">
            <arg line="-h ${TrueCM_Host}"/>
            <arg line='-f "${TrueSASE}/${Product_version}/${name}"'/>
        </exec>


    </target>
Run Code Online (Sandbox Code Playgroud)

这个脚本的作用是它将使用一些参数执行ssremove.exe,如图所示.

但是,上述脚本仅在参数$ {Product_version}包含单词"Extensions"时才有效,例如6.00_Extensions

否则,如果它们不包含"Extensions",则脚本应如下所示:

    <target name="Cleanup Snapshots" description="Cleanup TrueCM snapshots">
        <echo>Executing: ${TrueCM_App}\ssremove.exe  -h${TrueCM_Host} "${TrueCM_New_SS}"</echo>
        <exec executable="${TrueCM_App}\ssremove.exe"   failonerror="${TrueCM_Failon_Exec}">
            <arg line="-h ${TrueCM_Host}"/>
            <arg line='-f "${TrueSASE}/${name}"'/>
        </exec>


    </target>
Run Code Online (Sandbox Code Playgroud)

所以我的问题是我应该如何添加包含"Extensions"行的if else语句?或者如何检查"Extensions"字词是否存在?

oer*_*ers 6

有一个ant库:antlib(http://ant-contrib.sourceforge.net)

它支持if/else语句(http://ant-contrib.sourceforge.net/tasks/tasks/index.html)

网站上的例子:

<if>
 <equals arg1="${foo}" arg2="bar" />
 <then>
   <echo message="The value of property foo is bar" />
 </then>
 <else>
   <echo message="The value of property foo is not bar" />
 </else>
</if>


<if>
 <equals arg1="${foo}" arg2="bar" />
 <then>
   <echo message="The value of property foo is 'bar'" />
 </then>

 <elseif>
  <equals arg1="${foo}" arg2="foo" />
  <then>
   <echo message="The value of property foo is 'foo'" />
  </then>
 </elseif>


 <else>
   <echo message="The value of property foo is not 'foo' or 'bar'" />
 </else>
</if>
Run Code Online (Sandbox Code Playgroud)