macrodef

How to distribute each element of a list to argument of a task Ant ?

How to take the values of argument for a defined task into a list (of values) without to have to rewrite the task for each value of argument ? Example: I want to avoid to have to rewrite three time the same task for echoing three different values (value 1, value 2, value 3): <exec executable="cmd"> <arg value="/c"/> <arg value="value...

How to replace tree calls to a macrodef by only one ?

How to replace tree calls to "myMacro": <myMacro value="value 1"/> <myMacro value="value 2"/> <myMacro value="value 3"/> By only one call who would use a list of three elements: value 1, value 2, value 3 ...

Ant: How to reference file in Jar from macrodef in same Jar

I'm writing an Ant macrodef in an antlib file to be distributed in a Jar. As part of that macrodef, I'm copying the contents of one file to a temporary file and doing some filtering during the copy (replacing tokens and such). Now, this is all good and fine if the macrodef is referencing the file to copy on the file system. However, thi...

ANT. Override properties. Optional Execution in Single Target

I'm going to post a question that I've seen variants of elsewhere, but where I've not quite seen the answer I came up with. I'll subsequently post my answer. In order to modularize my build script using macros, I would like to put both the updatetask and the task I want to execute if it is not up to date, in the same macro. How do I do...

Making an ANT Macro more reusable

I have a simple macro (simplified version below). At the moment it assumes that there will be a single value for a single argument, however there might be multiple values for that argument. How can I pass in 0+ values for that argument so that the macro is usable in situations where I need to pass in 0+ values for that argument, not just...

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

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

Nant Build script undifined Issue

Hi, I have the following code in a nant build script: <project name="fgs"> <property name="build.dir" value="build"/> <property name="build.bin.dir" value="${build.dir}/bin"/> <fileset id="provider.1.0-references" basedir="${build.bin.dir}"> <include name="thenameofadllfile.*"/> </fileset> <macrodef name="build-dist"> <at...

Ant: how to write optional nested elements

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" /> ....