• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[Apache Ant ] Replace string for a param in antcontrib:for

ammalu pillai
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am trying to loop through a bunch of directories, obtain the path of files within them and replace part of path with another path and copy files to the said new path. I am stuck with how to replace the string.

ie. [b]c:/oldPath[/b]/foo.java to [b]c:/newPath[/b]/foo.java
I should match c:/oldPath and replace with with c:/newPath

My code looks like this ;


<target name="testCopyFiles">

<ac:for delimiter=","
trim="true" xmlns:ac="antlib:net.sf.antcontrib" >

<fileset id="devBuild" dir="${testSourcePath}" >
<include name="**/*.*" />
<path id="dpath">
<fileset refid="devBuild" />


<property name="before" value="@{dirsdfName}"/>
<script language="javascript">
var before = project.getProperty("before");
before = new String(before);
project.setNewProperty("after", before.replace("oldPathHere", "newPathHere"));



after is always echoing the first path and not looping to the next in the sequence. Is their any alternative approach to achieve this? please help. thanks much!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic