You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Ronald Klop <ro...@base.nl> on 2003/02/19 17:41:36 UTC

creating tasks

Hello,

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

<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 .../>
	</custom>
	<!-- 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"/>
</target>

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?

Greetings,

Ronald.