How to create a directory path with double backslash delimiters or forward slash delimiters?

I am writing a 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 

In the end, he writes:

 # KEY VALUE CurrentBuildFile=C:\Workspaces\ralph\trainer\current_build 

to the commonConfig.properties file.

I need to write:

 # KEY VALUE CurrentBuildFile=C:\\Workspaces\\ralph\\trainer\\current_build 

or I need to write:

 # KEY VALUE CurrentBuildFile=C:/Workspaces/ralph/trainer/current_build 

How can i do this?

+6
java windows unix ant
source share
1 answer

This is very similar to this question: Ant creates jsfl with backslashes instead of a slash

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"/> 
+9
source share

All Articles