蚂蚁和可用的任务 - 如果有什么不适吗? [英] Ant and the available task - what if something is not available?

查看:136
本文介绍了蚂蚁和可用的任务 - 如果有什么不适吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我使用任务,属性只能设置为TRUE,如果资源(比如文件)可用。如果不是,该属性未定义。

当我打印属性的值,它给真正的,如果资源可用,但在其他方面只是打印属性名称。

有没有办法为属性设置为某个值,如果资源的可用?我曾尝试使用前检查明确设置该属性,但随后蚂蚁抱怨:


[可] DE preCATED - 用于覆盖现有的属性。
[可]构建文件不应该重复使用不同的值相同的属性名称。


解决方案

您可以结合使用条件与不:

<一个href=\"http://ant.apache.org/manual/Tasks/condition.html\">http://ant.apache.org/manual/Tasks/condition.html

 &lt;条件属性=fooDoesNotExist&GT;
    &LT;而非&GT;
      &LT;提供文件路径=路径/要/富/&GT;
    &LT; /&不GT;
  &LT; /条件&gt;

When I use the task, the property is only set to TRUE if the resource (say file) is available. If not, the property is undefined.

When I print the value of the property, it gives true if the resource was available, but otherwise just prints the property name.

Is there a way to set the property to some value if the resource is not available? I have tried setting the property explicitly before the available check, but then ant complains:

[available] DEPRECATED -  used to override an existing property.
[available]   Build file should not reuse the same property name for different values.

解决方案

You can use a condition in combination with not:

http://ant.apache.org/manual/Tasks/condition.html

  <condition property="fooDoesNotExist">
    <not>
      <available filepath="path/to/foo"/>
    </not>
  </condition>

这篇关于蚂蚁和可用的任务 - 如果有什么不适吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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