¿Qué significa una variable con un símbolo @ en un Ant build.xml?

Can anyone tell me what an @ symbol before a variable means in ant build.xml file?

<subant target="@{target}">

preguntado el 09 de marzo de 12 a las 14:03

It means you are in a macro definition. -

1 Respuestas

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>

salida:

 [echo] foo =>  bar
 [echo] foo =>  baz

Vea 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>

salida:

[echo] ${foo} => bar

Vea Ant manual property

respondido 09 mar '12, 22:03

Strike ;-) Cheers || Slàinte mhath - Rebe

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.