Thomas Saxtoft wrote:

The thing is that the java.home I get from ant already contains the
backslash.

My script looks like this:
<target name="createServerXml">
   <replaceregexp file="${oc4j_home}/config/server.xml"
   match="&lt;java-compiler [^>]*/>"
   replace="&lt;java-compiler bindir=&quot;${java.home}/bin&quot;
extdirs=&quot;${java.home}/jre/lib/ext&quot;/>"/>
 </target>



The backslash is an escape character in regexpression land, so it
will not work using it in the replace attribute.

You need to convert the java.home before using it in the replace string.
Use pathconvert for this:
   <pathconvert targetos="unix" property="java.home.converted">
     <path path="${java.home}"/>
   </pathconvert>
   <echo>java.home.converted is ${java.home.converted}</echo>

Peer

I need to change the backslash contained in the property (java.home) to
a frontslash, before writing to the file. When written to the file the
backslash has disappeared, and thus it is too late to replace it.

By using ${java.home} the idea is always to get the correct path to jdk,
on either OS; Windows or Linux.

Thanx

Thomas


-----Original Message-----
From: Conelly, Luis (GE Energy, Non GE, GENE)
[mailto:[EMAIL PROTECTED] Sent: Monday, November 15, 2004 3:24 PM
To: Ant Users List
Subject: RE: Escapign backslash in java.home


why don't you use forward-slashes instead backslashes?

It is the same for Java and it fits on Win & *nix systems; of course, it
won't work the same on any OS, since in Win you have this horrible
drives concept (C: D: etc)

i.e

(for Win)
java.home=C:/j2se1.4.2/bin

(for *nix)
java.home=/usr/local/java/1.4.2/bin


bottom line, you have to write properties for both OSes and pick them on the fly by using something like <condition> [1] task. This kind of operation has been discused in this list several times [2]

Hope this helps
Regards
Luis

[1] http://ant.apache.org/manual/CoreTasks/condition.html
[2] http://marc.theaimsgroup.com/?l=ant-user&m=109760252905015&w=2
   http://marc.theaimsgroup.com/?l=ant-user&m=107631038006160&w=2

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to