Ant에서 macrodef를 디버그하려고합니다. 매개 변수의 내용을 요소로 표시하는 방법을 찾지 못하는 것 같습니다.Ant 매크로 정의 : 요소 매개 변수의 내용을 가져 오는 방법이 있습니까?
$ 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.
...
그래서 어떻게 든 (일부 확장 macrodef 구현하는 것이있을 수 있습니다) 내가 속성에 <elem />
의 내용을 얻을 수있는 방법 중 하나를 필요로 추측, 또는 나는 필요합니다
<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>
예 실행 <element-echo><elem /></element-echo>
일종의 내부 XML 트리를 인쇄 할 수 있습니다. 누구든지이 중 하나의 구현을 알고 있습니까? 데이터를 가져 오는 세 번째 예기치 않은 방법은 물론 환영합니다.
제공 요소가 내가 찾고있는 요소였습니다. 감사합니다! – clacke
보너스로, ' '은 추가 처리 없이도 XML 헤더를 추가 할 수 있습니다 (개미 1.8.4에서 테스트 됨). –