macrodef

Functionalizing few lines of code with ant macrodef

≯℡__Kan透↙ 提交于 2019-12-24 12:51:29
问题 I am trying to "function"alize few lines of ant-code using macrodef . But its resulting in error like : copy doesn't support the nested "my-macro" element. If I "inline" definition of my-macro of adding filterchian within copy-task it works. My test target looks like this - <target name="copy-files"> <sequential> <copy todir="abc" > <fileset dir="xyz"> <!--needy includes/excludes --> </fileset> <my-macro/> </copy> </sequential> </target> And my-macro looks like this: <macrodef name="my-macro"

Ant macrodef: Is there a way to get the contents of an element parameter?

倾然丶 夕夏残阳落幕 提交于 2019-12-22 04:34:28
问题 I'm trying to debug a macrodef in Ant. I cannot seem to find a way to display the contents of a parameter sent as an element. <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

Ant: how to write optional nested elements

别来无恙 提交于 2019-12-13 16:24:01
问题 Say that I need to do something like: <copy todir="${DEPLOYMENT_DIR}" overwrite="true"> <fileset dir="dir1" /> <fileset dir="dir2" /> <fileset dir="dir3" /> ... <if> <equals arg1="${SPECIAL_BUILD}" arg2="true"/> <then> <fileset dir="dir7" /> <fileset dir="dir8" /> ... </then> </if> </copy> (The real task is not copy, I'm just using it to illustrate the point.) Ant will complain that my task doesn't support nested <if> which is fair enough. I've been thinking along these lines: I could add a

How to <foreach> in a <macrodef>?

六月ゝ 毕业季﹏ 提交于 2019-12-10 16:25:36
问题 I have a xml just like below: <data> <foo>value1</foo> <foo>value2</foo> <foo>value3</foo> </data> I want to create macrodef which implements below function: <?xml version="1.0"?> <project name="OATS" default="execute" basedir="."> <xmlproperty file="data.xml" collapseAttributes="true"/> <target name="execute"> <foreach list="${data.foo}" target="runScript" param="script"/> </target> <target name="runScript"> <echo>Doing things with ${script}</echo> </target> </project> Anybody knows how to ?

Ant macrodef: Is there a way to get the contents of an element parameter?

早过忘川 提交于 2019-12-05 03:32:00
I'm trying to debug a macrodef in Ant. I cannot seem to find a way to display the contents of a parameter sent as an element. <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

The differences between if else and #if #else #endif

风流意气都作罢 提交于 2019-12-02 23:56:32
问题 I am confused between the if / else and #if / #else / #endif constructs. What are the differences between them? In which specific situations should I use each of them? 回答1: I am confused about the if/else and #if/#else/#endif. It seems that they have the same logic functionality. Can I ask what's the differences between them? #if , #else and #endif belong to preprocessing. They are not executed but are instructions for textual replacement. You can think of them as a kind of automatic "search