有人能告诉我在ant build.xml文件中变量前面的@符号是什么意思吗?
<subant target="@{target}">
(core)ant中没有变量,只有属性和属性
@{foo}是用于访问macrodef内部macrodef属性值的语法,即:
<project name="tryme">
<macrodef name="whatever">
<attribute name="foo" default="bar"/>
<sequential>
<echo>foo => @{foo}</echo>
</sequential>
</macrodef>
<!-- testing 1, foo attribute not set, will use default value -->
<whatever/>
<!-- testing 2, set attribute foo to 'baz'-->
<whatever foo="baz"/>
</project>
输出:
[echo] foo => bar
[echo] foo => baz
请参阅Ant手动宏定义
而${foo}是访问属性值的语法:
<project name="demo">
<property name="foo" value="bar"/>
<echo>$${foo} => ${foo}</echo>
</project>
输出:
[echo] ${foo} => bar
请参阅Ant手动属性