views:

41

answers:

2

Hi,

I'm writing a velocity macro within which I have some ant tasks. Within a #foreach loop in the velocity macro, I have a pathconvert task:

#foreach(<iterate through something>)        
        <pathconvert property='filename' refid='swf.file'>
          <mapper>
            <chainedmapper>
                <flattenmapper/>
                <globmapper from='*-d.swf' to='*'/>
            </chainedmapper>
          </mapper>
        </pathconvert>
#end

The problem I have is that the 'filename' property gets set only once, during the first iteration, since properties in ANT are immutable. But I need the filename to be set during each iteration. Is there a way to get this done?

If there was a way to reset the property, I could do that at the end of each iteration. Or is there a better way to do this? Any help would be highly appreciated!

Thanks in advance, Anand

+1  A: 

You could use ant-contrib's variables. They act like mutable properties.

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

Nate
A: 

Use the new lexically scoped properties in Ant 1.8:

"Lexically scoped local properties, i.e. properties that are only defined inside a target, sequential block or similar environment."

Annoucement.

Properties in Ant were designed to be immuatable, but they gave in to popular demand and gave us variables. Your alternative is to write a custom task ( in Java or a Dynamic Language) but this seems like a good compromise.

Julian Simpson