在蚂蚁如何检查的条件,并根据其价值打印一条消息? [英] How check for a condition in ant and depending on its value print a message?

查看:130
本文介绍了在蚂蚁如何检查的条件,并根据其价值打印一条消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一小块code的请给看看它,然后按照说明....

This is a small piece of code please give a look at it then follow the description....

    <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>

我想,当过platform.id包含任何窗口的姓应该打印邮件执行Windows家族BUILD 但问题是,它是打印此消息甚至当家庭是UNIX的。

I want that when ever platform.id contains any of the windows family name it should print the message EXECUTING WINDOWS FAMILY BUILD but the problem is that it is printing this message even when the family is unix.

我觉得要么我没有正确地检查条件,否则我正在做一些其他的错误。结果
有人可以帮我这个好吗?

I think either I am not checking the condition properly or else i am doing some other mistake.
Can someone help me out with this please?

推荐答案

彼得试图解释,你必须明确指定属性名称。请尝试以下方法,使您的code的工作:

Peter is trying to explain that you must explicitly specify the property name. Try the following to make your code work:

<project name="demo" default="Mytarget">

    <condition property="windoze">
        <or>
            <equals arg1="${param1}" arg2="win-x86"/>
            <equals arg1="${param1}" arg2="win-x86-client"/>
            <equals arg1="${param1}" arg2="win-x64"/>
        </or>
    </condition>

    <target name="Mytarget" if="windoze">
        <echo message="executing windows family build:::${param1}"/>
    </target>

</project>

有一个更好的解决办法是利用内置ANT的条件任务。

A better solution would be to make use of operating system tests built into ANT's condition task.

<project name="demo" default="Mytarget">

    <condition property="windoze">
        <os family="windows"/>
    </condition>

    <target name="Mytarget" if="windoze">
        <echo message="executing windows family build:::${os.name}-${os.arch}-${os.version}"/>
    </target>

</project>

这篇关于在蚂蚁如何检查的条件,并根据其价值打印一条消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆