ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve Cohen" <>
Subject RE: pathconvert - why doesn't this work?
Date Wed, 20 Feb 2002 02:40:07 GMT

Thanks, Diane, at least for confirming that I'm not crazy.

I am very sorry that I "discovered" <pathconvert> this morning.  I wasted much too much
time on it.  I had already decided to roll my stuff back unless someone could come up with
an obvious fix I was overlooking.

As I think you surmised, my "sample" was just to demonstrate the flaw, not what I was REALLY
trying to do.  Here's what I'd LIKE to be able to do.  We have a number of programs that are
launched from batch files.  These batch files do things like call other batch files and we
have found that relative paths do not work and we've always hardcoded full paths.  Then we
got smarter and started using replaceable parameters and that worked pretty well.

But it still always bothered me that that I have this one property which I call "dist.dir.bin"
which is the directory into which ant dumps the modified binaries with the replaced parameters
and another property "runtm.bin" which represents the directory from which it is run.  Logically,
these are the same directory or at worst, a root-to-root mapping, differing only in slash
vs. backslash.  <pathconvert> ought to be able to handle this, and it isn't.  This means
that every little change in build environment entails a tweaking period, especially when doing
test builds for my own code changes.  It's so annoying and unnecessary.

And while we're at it, I can't tell since I've never gotten the pathconvert map to work right,
but can the "from" and "to" parameters handle embedded property strings as well as literals?

I may have a go at fixing this. ...

Or else, we should really get smart and port this whole mess to unix :-)

-----Original Message-----
From:	Diane Holt []
Sent:	Tue 2/19/2002 7:00 PM
To:	Ant Users List
Subject:	Re: pathconvert - why doesn't this work?
--- Steve Cohen <> wrote:
> What am I doing wrong? (ant 1.5a built about a week ago)

Nothing -- it's just that <pathconvert> is a little woobly. See:

You're trying to deal with a Unix-style pathname, but you're running on a
Win* box, so by the time <path> has had at your "/build", it's already
become "E:\build", so there's nothing to match in the mapping.

What you need to do is to account for that weirdness:
<project name="test" default="testtarget">
  <property name="dist.dir" value="/build"/>
  <target name="testtarget">
    <pathconvert pathsep=":" property="p1">
        <pathelement location="${dist.dir}"/>
      <map from="E" to="C"/>
    <echo message="mapped ${dist.dir} ==> ${p1}"/>

Of course, that sucks, because then you've got that hard-coded "E" drive
letter in there, and that's probably not guaranteed to always be the drive
this is being run on, right?  <pathconvert> should probably be re-thought,
but in the meantime... Recommendation: Find another way to do what you
need to do without using <pathconvert> :)



Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games

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

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message