Home > Apache Ant, General, Technology > Ant for Loop

Ant for Loop

This post explains you how to apply for-each iteration in your ant build script.


  1. You should’ve downloaded ant-contrib jar from http://ant-contrib.sourceforge.net/#install
  2. Add the jar into <ANT_HOME>/lib directory


You first need to refer to your contrib jar in the <project> tag of build.xml

<?xml version="1.0" encoding="UTF-8"?>
<project name="ForTest" default="build" basedir="." xmlns:ac="antlib:net.sf.antcontrib">
 <taskdef uri="antlib:net.sf.antcontrib"
 <target name="test">
 <echo message="The first five letters of the alphabet are:"/>
 <ac:for list="a,b,c,d,e" param="letter">
 <echo>Letter @{letter}</echo>

 <target name="build" depends="test" description="Test For loop"/>

Save this as build.xml in your desired directory.

Note that specifying namespace ac: is extremely important to successfully execute build script.

Your script should execute and out put should get generated as shown below:

  1. July 20, 2014 at 3:09 PM

    Mediation: This is one of the most significant and cheaper alternative to hiring individual lawyers.
    If the situation or altercation presents itself in an act of misconduct at work.
    Taking an advantage of such a situation of car accident attorney, Jacksonville is making money with the huge number of cases filed each day.


  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: