当我使用该任务时,如果资源(例如文件)可用,则该属性仅设置为TRUE.如果没有,则该属性未定义.
当我打印属性的值时,如果资源可用,则为true,否则只打印属性名称.
如果资源不可用,有没有办法将属性设置为某个值?我已经尝试在可用检查之前显式设置属性,但是然后ant抱怨:
[available] DEPRECATED - used to override an existing property. [available] Build file should not reuse the same property name for different values.
Ale*_*ler 15
您可以结合使用条件而不是:
http://ant.apache.org/manual/Tasks/condition.html
<condition property="fooDoesNotExist">
<not>
<available filepath="path/to/foo"/>
</not>
</condition>
Run Code Online (Sandbox Code Playgroud)
小智 8
<available filepath="/path/to/foo" property="foosThere" value="true"/>
<property name="foosThere" value="false"/>
Run Code Online (Sandbox Code Playgroud)
foosThere的分配只有在您的可用性检查尚未设置为true时才会成功.