Loop in Ant?

V

vunet.us

How do I loop in Ant?

I have a <property name='xxx' value='yyy'/> where I have a set of
targets to perform for value 'yyy'. But I want to have an array of
'yyy' values, i.e. to perform the same set of commands for different
values of the property or loop through values.

Thanks.
 
D

Daniel Dyer

How do I loop in Ant?

I have a <property name='xxx' value='yyy'/> where I have a set of
targets to perform for value 'yyy'. But I want to have an array of
'yyy' values, i.e. to perform the same set of commands for different
values of the property or loop through values.

Thanks.


Ant doesn't really support this. You can declare a macro so that you can
perform the same tasks for different inputs.

http://ant.apache.org/manual/CoreTasks/macrodef.html

Alternatively, you can download the Ant contrib tasks. These include a
foreach task.

http://ant-contrib.sourceforge.net/tasks/tasks/index.html

Dan.
 
A

Andy Dingley

How do I loop in Ant?

You don't. In an attempt to force declarative coding style over
procedural, Ant is deliberately (if not perhaps correctly) light on
control structures to do this.

If your set if file-related, then you might be apply to use Apply (Ant
1.7+)

Otherwise there's a foreach task from ant-contrib, but this limits
easy deployment of your Ant buildfile to other Ant installations that
might not have this task installed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top