蚂蚁:如何检查是否一个属性是否存在? [英] Ant: How to check if a property exists?

查看:124
本文介绍了蚂蚁:如何检查是否一个属性是否存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何检查使用蚂蚁属性的存在?
我打开使用Ant-的contrib,如果蚂蚁不提供一些有用的东西。
此外,蚂蚁的contrib有断言的任务,它提供了存在,但断言是不是我需要在这里,因为我想preFER一个boolean返回值。
(蚂蚁新手...)

How do I check the existence of a property using ant? I am open to the use of ant-contrib, if ant doesn't provide some thing useful. Also, ant-contrib has assert task, which provides "exists", but assertion is not what I need here, since I would prefer a boolean return value. (ant newbie...)

推荐答案

您可以使用条件任务与使用isset 条件。

You can use the Condition task with an isset condition.

<project default="test">

  <property name="a" value="a"/>

  <target name="test">

    <condition property="a.set" else="false">
      <isset property="a"/>
    </condition>

    <condition property="b.set" else="false">
      <isset property="b"/>
    </condition>

    <echo message="a set ? ${a.set}"/>
    <echo message="b set ? ${b.set}"/>

  </target>
</project>

输出:

test:
     [echo] a set ? true
     [echo] b set ? false

这篇关于蚂蚁:如何检查是否一个属性是否存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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