# ant-user mailing list archives

##### Site index · List index
Message view
Top
From Diane Holt <hol...@yahoo.com>
Subject RE: <replace> in .properties with Windows paths? (/ vs \\)
Date Tue, 30 Apr 2002 19:25:57 GMT
--- Joshua Kneubuhl <joshua.kneubuhl@demandtec.com> wrote:
> How can I use <pathconvert> to _change_ the value of ant properties?

You don't -- you can't. My suggestion is to have your properties file(s)
values that contain paths use foreslashes so you don't have to worry about
things like backslashes getting swallowed or needing to be escaped to
avoid that happening.

To use <pathconvert> to convert a path that's set in a property, you'd
need to define a <path>, referencing the property in the <path>'s element.
For example, if your have a property ${foo.path}, and it contains something like "D:/some/path/to/foo.exe" (note the foreslashes), and you reference that property in defining a <path> datatype: <path id="foo.path"> <path location="${foo.path}"/>
</path>
the path defined by (<path> ID) foo.path will be D:\some\path\to\foo.exe,
without your having had to do any <pathconvert>'ing at all. The same would
be true if you had a property like:
library.path=D:/lib:D:/usr/lib:D:/usr/local/lib
and did:
<path id="lib.path">
<path path="\${library.path}"/>
</path>
It would become D:\lib;D:\usr\lib;D:\usr\local\lib.

Now, if you wanted to convert the above path to a Unix-style path, *then*
you'd use <pathconvert>, with 'targetos="unix"' and <map>'d to what you
want.

Of course, if you never want to do that kind of conversion, you don't even
need to set <path>'s for your path-type properties at all, if you're
refencing the properties in attributes/elements that do the right thing
with them (ie., convert them on-the-fly to what they should be for your
current OS). For example, if you're referencing them in a <classpath>
element in a <javac> task, just reference the property (with foreslashes
and all) and it'll be fine.

Diane

=====
(holtdl@yahoo.com)

__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message