【问题标题】:to check if the file is available or not in ant检查文件在ant中是否可用
【发布时间】:2014-09-14 20:57:28
【问题描述】:

要求:检查文件是否可用,然后根据真假值执行一些任务。

我正在使用任务:

<varNested name="path" value="/user1/abc.jar"/>
<available file="${path}" property="file.available"/>

问题 1: 现在,当我尝试打印此属性时:

<echo message="value of file is available is : ${file.available}"/>

而不是打印值 true 它打印 ${file.available}

问题 2: 这段代码 sn-p 会起作用吗?如果不是,应该用什么代替equalsNested? ...

        </then>
        <else>
           ...
        </else>
        </if>

【问题讨论】:

标签: ant ant-contrib


【解决方案1】:

试试这个:

<property name="abc" value="false" />
<available file="somefile" property="abc" value="true"/>
<echo message="value of file is available is : ${abc}"/>

【讨论】:

  • 感谢您的指导...使用上面的代码,它抱怨我试图设置同一属性的值 2 次。但这有效:&lt;property name="abc" value="false" /&gt; &lt;available file="somefile" property="abc" /&gt; &lt;echo message="value of file is available is : ${abc}"/&gt;
  • 分享很棒!谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-04-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多