ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik Hatcher" <>
Subject Re: <replace> in .properties with Windows paths? (/ vs \\)
Date Tue, 30 Apr 2002 18:03:49 GMT
One idea that may work for you is to use the <propertyfile> task to write
the property file instead using an <entry> for some.exec.path.  It will
ensure that everything is escaped properly.


----- Original Message -----
From: "Joshua Kneubuhl" <>
To: <>
Sent: Tuesday, April 30, 2002 2:01 PM
Subject: <replace> in .properties with Windows paths? (/ vs \\)

Hi everyone,

I have some java code that references file paths from a .properties file.
I'm currently using ant to do some token replacement based on absolute
paths, and it is causing some troubles when running from NT.

For instance, I have a file:


and java code:
String execPath = System.getProperties().getProperty("some.exec.path");
System.out.println("I am about to Runtime.exec(" + execPath + ")");

and my ant script:

<property name="my.bin.dir" value="${basedir}/deploy/bin"/>

<replace file="">
<replacefilter token="@SOME_TOKEN@" value="${my.bin.dir}/foo.exe"/>

When executed from a basedir of D:\foo\bar\frog (set by ant), my program
"I am about to Runtime.exec(D:foobarfrog/deploy/bin/foo.exe)"  (broken)

If my has

"I am about to Runtime.exec(D:\foo\bar\frog\deploy\bin\foo.exe)" (success)

I saw the <pathconvert> task, but it was not clear to me that one could
pathconvert ant properties (even though a property specifies a path).

This brings up another point:  I would like to use ant to do "cross platform
deployment" by using an NT machine to do builds (and path configuration) for
UNIX boxes.  If I were to do an "% ant release -Dosname=AIX" on an NT
machine, all the File instances created by ant should come out as /

Is it possible to tell ant to "use UNIX paths" instead of the system

I am currently considering a custom ant task to munge all the Project
properties-  if run as a dependency of all other tasks, it could convert all
the \ to / in the ant properties.  Java File objects seem ok with / as a
file separator even on Windows machines, so I think this will be ok.


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message