Reputation: 811
In my build file i have an ant target in which i have following snippet ,
<replaceregexp replace="custom.dir=${basedir}/tasks/custom" byline="true" file="${basedir}/MyApp/configuration.properties">
<regexp pattern="custom.dir=(.*)"/>
</replaceregexp>
I wanted to replace the "custom.dir" property with a path in the "configuration.properties" file , however once i execute my target i get the entry for "custom.dir" property modified to
custom.dir=c:arenaplaygroundmytestapp/tasks/custom
instead of
custom.dir=c:\arena\playground\mytestapp/tasks/custom
What should i do to write the path correctly to the "configuration.properties" file with proper file separators . I am on windows and ant used is ant 1.8 .
Upvotes: 3
Views: 3740
Reputation: 3279
When you are trying to write WINDOW_STYLE_PATH to your file, then WINDOW_FILE_SEPARATOR is recognized as escaping sequence character. So you can change the path in unix style before writing it to the file. Pathconvert will assist you to convert the path...
<pathconvert property="new" dirsep="/">
<path location="${basedir}"/>
</pathconvert>
<echo message="${new}"/>
<replaceregexp replace="custom.dir=${new}/tasks/custom" byline="true" file="${basedir}/configuration.properties">
<regexp pattern="custom.dir=(.*)"/>
</replaceregexp>
Upvotes: 5