如何检查 ant 中的条件并根据其值打印消息?

use*_*517 0 ant

这是一小段代码,请看一下然后按照说明进行操作......

    <condition property="${param1}">
            <or>
                <istrue value="win-x86"/>
                <istrue value= "win-x86-client"/>
                <istrue value= "win-x64"/>
            </or>
     </condition>
    <target name="Mytarget" if="${param1}">
        <echo message="executing windows family build:::${param1}"/>
    </target>
<target name="print.name" >
    <antcall target="win-x86-build">
       <param name="param1" value="${platform.id}"/>
    </antcall>
</target>
Run Code Online (Sandbox Code Playgroud)

我希望当 platform.id 包含任何 Windows 系列名称时,它应该打印该消息EXECUTING WINDOWS FAMILY BUILD,但问题是即使该系列是 Unix,它也会打印此消息。

我想要么是我没有正确检查情况,要么是我犯了其他错误。
有人可以帮我解决这个问题吗?

小智 5

从 ant 1.9.1 开始你可以这样做:

<project name="tryit" xmlns:if="ant:if" xmlns:unless="ant:unless">
   <exec executable="java">
     <arg line="-X" if:true="${showextendedparams}"/>
     <arg line="-version" unless:true="${showextendedparams}"/>
   </exec>
   <condition property="onmac">
     <os family="mac"/>
   </condition>
   <echo if:set="onmac">running on MacOS</echo>
   <echo unless:set="onmac">not running on MacOS</echo>
</project>
Run Code Online (Sandbox Code Playgroud)