Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!