我想澄清ANT脚本中的if和unless语句
我有以下代码:
<condition property="hasExtensions"> <contains string="${Product_version}" substring="Extensions"> </condition> <exec executable="${TrueCM_App}\ssremove.exe" unless="hasExtensions"> ... </exec>
这是否意味着上述< exec>如果Product_version不包含字符串“Extensions”,则会执行ssremove.exe吗?
那么相反的情况如何:如果它包含字符串“Extensions”?我的代码看起来像这样:
<condition property="hasExtensions"> <contains string="${Product_version}" substring="Extensions"> </condition> <!-- here below it does not have the string "Extensions" --> <exec executable="${TrueCM_App}\ssremove.exe" unless="hasExtensions"> ... </exec> <!-- below is for if it has the string "Extensions" --> <exec executable="${TrueCM_App}\ssremove.exe" if="hasExtensions"> ... </exec>
你有正确的逻辑,但我不确定< exec> task接受if和unless属性.有关详细信息,请参阅
docs.
原文链接:https://www.f2er.com/xml/292728.html你可能需要包装< exec>检查条件的目标中的任务.例如:
<condition property="hasExtensions"> <contains string="${Product_version}" substring="Extensions"> </condition> <target name="ssremove" unless="hasExtensions"> <exec executable="${TrueCM_App}\ssremove.exe"> ... </exec> </target>
然后,如果你运行ant ssremove,我想你会得到你想要的.