Estoy intentando depurar un macrodef en Ant. Parece que no puedo encontrar una forma de mostrar el contenido de un parámetro enviado como un elemento.Macrodef Ant: ¿Hay alguna manera de obtener el contenido de un parámetro de elemento?
<project name='debug.macrodef'>
<macrodef name='def.to.debug'>
<attribute name='attr' />
<element name='elem' />
<sequential>
<echo>Sure, the attribute is easy to debug: @{attr}</echo>
<echo>The element works only in restricted cases: <elem /> </echo>
<!-- This works only if <elem /> doesn't contain anything but a
textnode, if there were any elements in there echo would
complain it doesn't understand them. -->
</sequential>
</macrodef>
<target name='works'>
<def.to.debug attr='contents of attribute'>
<elem>contents of elem</elem>
</def.to.debug>
</target>
<target name='does.not.work'>
<def.to.debug attr='contents of attribute'>
<elem><sub.elem>contents of sub.elem</sub.elem></elem>
</def.to.debug>
</target>
</project>
Ejemplo ejecute:
$ ant works
...
works:
[echo] Sure, the attribute is easy to debug: contents of attribute
[echo] The element works only in restricted cases: contents of elem
...
$ ant does.not.work
...
does.not.work:
[echo] Sure, the attribute is easy to debug: contents of attribute
BUILD FAILED
.../build.xml:21: The following error occurred while executing this line:
.../build.xml:7: echo doesn't support the nested "sub.elem" element.
...
así que supongo que necesita ya sea una forma de obtener los contenidos del <elem />
en una propiedad de alguna manera (algunos aplicación macrodef extendida podría tener que), o necesito una tipo de <element-echo><elem /></element-echo>
que podría imprimir cualquier árbol XML que ponga dentro. ¿Alguien sabe de una implementación de cualquiera de estos? Cualquier tercera forma no anticipada de obtener los datos es, por supuesto, también bienvenida.
El ' ' Elemento era exactamente lo que estaba buscando, ¡gracias! –
clacke
Como una ventaja, el ' ' funciona incluso sin el procesamiento adicional para agregar los encabezados XML (probados en la hormiga 1.8.4). –