Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

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

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 ;

[code]

<target name="testCopyFiles">

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

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

<ac:sequential>
<echo>@{dirsdfName}</echo>

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


<echo>${after}</echo>


</ac:sequential>
</ac:for>
</target>
[/code]

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
Boost this thread!