ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian Pontarelli" <>
Subject TaskContainer and setProperty
Date Thu, 05 Sep 2002 16:03:38 GMT

I'm sure that this stuff has been covered multiple times before, but I'm
having trouble locating stuff in the archives as well as location in the

Here's my dilemna:
I have a foreach tag (groan right?) that does multiple things. It calls to
targets and executes embedded tasks. The call to targets works fine with the
whole delegation to the "antcall" task (which is annoying, but works). The
embedded tasks, doesn't work at all.

Here's what my build file looks like

<foreach list="foo,bar" property="current">
  <echo message="Current is ${current}"/>

My code is roughly this:

// If there are embedded tasks, set the local property and then
// execute those. The 'tasks' variable is a List that is populated
// via the addTask(Task) method
if (!tasks.isEmpty()) {
    project.setProperty(property, token);

    Iterator iter = tasks.iterator();
    Task curTask;
    while (iter.hasNext()) {
        // curTask.setProject(project); tried this to no avail
        curTask = (Task);

This does not work because the embedded tasks do not see the property at
all. They don't even see the first value or anything. Here's my output:

[foreach] Current is ${current}
[foreach] Current is ${current}

First off, can someone point me the the code in the ant framework that makes
properties immutable so that you must use the "antcall" hack to call other
targets correctly? Also, could someone please explain to me what ant is
doing when it constructs the embedded tasks that prevent them from seeing
properties? Last, does anyone have any work-arounds for this problem?

Brian Pontarelli

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message