I am writing a directory path to a text file from ant, which is later read by a Java Application to find another file.
In my ant script I have:
<property name="fulltrainer.dir" location="${trainer.dir}" />
<echo file="${trainer.dir}/properties/commonConfig.properties"># KEY VALUE
CurrentBuildFile=${fulltrainer.dir}\current_build</echo>
in the build.properties file trainer.dir is set to:
trainer.dir=../trainer
It ends up writing:
# KEY VAL开发者_如何学PythonUE
CurrentBuildFile=C:\Workspaces\ralph\trainer\current_build
to the commonConfig.properties file.
I need it to write:
# KEY VALUE
CurrentBuildFile=C:\\Workspaces\\ralph\\trainer\\current_build
or, I need it to write:
# KEY VALUE
CurrentBuildFile=C:/Workspaces/ralph/trainer/current_build
How can I do that?
This looks a lot like this question: Ant produces jsfl with backslashes instead of slashes
So, try using the pathconvert
task.
<pathconvert targetos="unix" property="fulltrainer.unix_dir">
<path location="${trainer.dir}"/>
</pathconvert>
<property name="cf.props" value="${trainer.dir}/properties/commonConfig.properties"/>
<echo file="${cf.props}" message="# KEY VALUE"/>
<echo file="${cf.props}" append="yes" message="CurrentBuildFile=${fulltrainer.unix_dir}/current_build"/>
精彩评论