Ant 和可用任务 - 如果某些东西不可用怎么办? [英] Ant and the available task - what if something is not available?
问题描述
当我使用任务时,如果资源(比如文件)可用,则该属性仅设置为 TRUE.如果不是,则该属性未定义.
当我打印属性的值时,如果资源可用,它会给出 true,否则只打印属性名称.
如果资源不可用,有没有办法将属性设置为某个值?我曾尝试在可用检查之前明确设置属性,但蚂蚁抱怨:
<前>[可用] 已弃用 - 用于覆盖现有属性.[可用] 构建文件不应为不同的值重用相同的属性名称.您可以将条件与 not 结合使用:
http://ant.apache.org/manual/Tasks/condition.html
<不><available filepath="path/to/foo"/></不></条件>
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>
这篇关于Ant 和可用任务 - 如果某些东西不可用怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!