3

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 .

1 Answer 1

5

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.