ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ronald Klop <>
Subject creating tasks
Date Wed, 19 Feb 2003 16:41:36 GMT

I made the attached code today for creating tasks easily.
The idea was using something like this:

<taskdef name="custom" classname="nl.base.util.CustomTask">
	<classpath refid="local.classpath"/>

<target name="test">
	<!-- define a new task named task1 -->
	<custom action="new" name="task1" args="dir">
		<echo>Compiling ${task1.dir}</echo>
		<javac srcdir="${task1.dir}"/>
		<delete .../>
	<!-- run the taks named task1 -->
	<custom action="do" name="task1" args="dir=/bla1"/>
	<custom action="do" name="task1" args="dir=/bla2"/>
	<custom action="do" name="task1" args="dir=/bla3"/>
	<custom action="do" name="task1" args="dir=/bla4"/>

The output would than be:
[echo] Compiling /bla1
[javac] ...
[delete] ...
[echo] Compiling /bla2
[javac] ...
[delete] ...
[echo] Compiling /bla3
[javac] ...
[delete] ...
[echo] Compiling /bla4
[javac] ...
[delete] ...

So, my idea is to make a task which can execute a couple of other tasks, 
which can be defined in the build.xml.

This works, but the problem is, that the arguments are evaluated at 
creation of the task and not at execution.
So in the above example it wil print 'Compiling ${task1.dir}', because 
the property 'task1.dir' isn't known until execution.

Is there a solution for this? Or are there other tasks which do the same 
as I want?



View raw message