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.
Erik
----- Original Message -----
From: "Joshua Kneubuhl" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
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 foo.property file:
some.exec.path=@SOME_TOKEN@
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="foo.property">
<replacefilter token="@SOME_TOKEN@" value="${my.bin.dir}/foo.exe"/>
</replace>
When executed from a basedir of D:\foo\bar\frog (set by ant), my program
outputs:
"I am about to Runtime.exec(D:foobarfrog/deploy/bin/foo.exe)" (broken)
If my foo.properties has
some.exec.path=D:\\foo\\bar\\frog\\deploy\\bin\\foo.exe
"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
default?
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.
Cheers,
josh
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>