Can anyone tell me what an @ symbol before a variable means in ant build.xml file?
<subant target="@{target}">
There are no variables in (core) ant, but properties and attributes.
@{foo} is the syntax for accessing the value of a macrodef attribute inside a macrodef, i.e. :
<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>
output :
[echo] foo => bar
[echo] foo => baz
See Ant manual macrodef
Whereas ${foo} is the syntax for accessing the value of a property :
<project name="demo">
<property name="foo" value="bar"/>
<echo>$${foo} => ${foo}</echo>
</project>
output :
[echo] ${foo} => bar
See Ant manual property
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With