How to convert path slashes during build

It happens many times that you need to set a property using path defined in the build process and convert slashes according to the relevant OS, and do it while coping the property file to the target directory during build.
Here is a simple example how to do it with Ant:

let's say mypath is defined as "module\conf\xml"
in your the path should appear as:

in your build.xml (or in pom.xml when using antrun plugin with maven):
<pathconvert property="mypathfixed" dirsep="/">
         <path location="${mypath}"/>
<copy todir="${my.target_dir}" filtering="true">
            <fileset dir="${basedir}/src/main/conf" includes=""/>
            <filterset recurse="true">
                  <filter token="mypath" value="${mypathfixed}"/>

copied will have your property defined as:

More useful examples how to use pathconvert:

DevOps Architect

DevOps Group
Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at