2013-07-15 181 views
0

我有一只蚂蚁条件是这样的:蚂蚁条件块

<condition property="create_stub"> 
    <and> 
     <available file="${create_stub_command_file}" property="stub_script.present" /> 
     <isset property="packaged_stub_file"/> 
    </and> 
    </condition> 

我的理解是:如果create_stub_command_file存在,则设置stub_script.present=true。但我不确定

<isset property="packaged_stub_file"/> 

这是干什么的?它是如何改变整体状况的。即在这种情况下,条件块是否会评估为真?

回答

0

Equivolent伪代码:

if (File($create_stub_command_file).exists) then 
    property["stub_script.present"] := true 
end 

if (File($create_stub_command_file).exists AND property["property["stub_script.present"] != NULL) then 
    property["create_stub"] := true 
end 

原谅任何错误......我觉得条件块棘手,他们需要大量的测试。建议您尽量保持简单。 ANT不是一种编程语言。

1

有轻微的错误?我不相信property="stub_script.present"是做什么的。它应该是:

<condition property="create_stub"> 
    <and> 
     <available file="${create_stub_command_file}"/> 
     <isset property="packaged_stub_file"/> 
    </and> 
</condition> 

所有这些条件语句做的是设置一个名为create_stub属性。它将设置该属性,如果文件或目录都称为{$create_stub_command_file}存在,并且属性packaged_stuf_file设置为任何值。 packaged_stub_file可以设置为false,空字符串,trueYES! YES! YES!或任何设置,只要它被设置。

所以,现在你可以使用这个属性作为测试一个目标:

<target name="package_stub" 
    if="create_stub"> 
    <blah...blah...blah/> 
    <yadda...yadda...yadda/> 
</target> 

这一目标,package_stub如果属性package_stub设置将只执行。如果上述<condition>为真,它将被设置。

<condition>声明应该在任何目标之外,所以它会在执行任何目标之前执行。