You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Ken Gentle <Ke...@iMedium.com> on 2001/12/11 14:06:38 UTC

Help with 'pathconvert', please!

Hello all - I'm having a really hard time making 'pathconvert' do what I 
think it should.  The build file below is supposed to replace the first 
several characters of a path with a platform specific root, but the 
substitutions don't happen like I thought they should:

<?xml version="1.0"?>
<project name="imf" default="dump-info" basedir=".">
   <property name="tools.unix.iplanet"    value="/opt" />
   <property name="tools.windows.iplanet" value="D:\" />
   <property name="PATH.PREFIX.TOKEN"     value="/prefix" />
   <property name="home.iplanet" 
value="${PATH.PREFIX.TOKEN}/iplanet/ias6/ias"/>

   <path id="path.iplanet">
     <pathelement location="${home.iplanet}/classes/java/iasclient.jar}" />
   </path>

   <target name="generate_classpath" >
     <echo message="BEFORE: PATH.PREFIX.TOKEN=${PATH.PREFIX.TOKEN}"/>
     <echo message="BEFORE: home.iplanet=${home.iplanet}"/>
     <echo message="BEFORE: tools.windows.iplanet=${tools.windows.iplanet}"/>
     <echo message="BEFORE: classpath.project=${classpath.project}"/>
     <pathconvert targetos="windows" property="classpath.project" 
refid="path.iplanet">
       <map from="${PATH.PREFIX.TOKEN}" to="${tools.windows.iplanet}" />
     </pathconvert>
     <echo message="AFTER:  classpath.project=${classpath.project} "/>
   </target>

   <target name="dump-info" depends="generate_classpath">
     <echo message="ant.version=${ant.version}" />
     <echo message="ant.file=${ant.file}" />
     <echo message="" />
     <echo message="java.vm.info=${java.vm.info}" />
     <echo message="java.vm.name=${java.vm.name}" />
     <echo message="java.vm.vendor=${java.vm.vendor}" />
     <echo message="java.vm.version=${java.vm.version}" />
     <echo message="os.arch=${os.arch}" />
     <echo message="os.name=${os.name}" />
     <echo message="os.version=${os.version}" />
     <echo message="" />
     <echo message="classpath.project=${classpath.project}" />
   </target>

</project>

Executing ant against this produces the following:

Buildfile: build.xml

generate_classpath:
      [echo] BEFORE: PATH.PREFIX.TOKEN=/prefix
      [echo] BEFORE: home.iplanet=/prefix/iplanet/ias6/ias
      [echo] BEFORE: tools.windows.iplanet=D:\
      [echo] BEFORE: classpath.project=${classpath.project}
      [echo] 
AFTER: 
classpath.project=e:\prefix\iplanet\ias6\ias\classes\java\iasclient.jar}

dump-info:
      [echo] ant.version=Ant version 1.4 compiled on October 11 2001
      [echo] ant.file=e:\home\kgentle\work\head\imf_ii\build.xml
      [echo]
      [echo] java.vm.info=mixed mode
      [echo] java.vm.name=Java HotSpot(TM) Client VM
      [echo] java.vm.vendor=Sun Microsystems Inc.
      [echo] java.vm.version=1.3.0-C
      [echo] os.arch=x86
      [echo] os.name=Windows NT
      [echo] os.version=4.0
      [echo]
      [echo] 
classpath.project=e:\prefix\iplanet\ias6\ias\classes\java\iasclient.jar}

BUILD SUCCESSFUL

Total time: 1 second

Why does 'pathconvert' ignore the substitution of "D:\" for "/prefix"?
Why does it prepend the "e:\" instead?
Should I be doing this a different way?

Thanks in advance!

	Ken
==========================================================================
J. Kenneth Gentle (Ken)       | Phone: (610)964-2800  FAX: (610)964-9590
iMedium                       | Email: Ken.Gentle@iMedium.com
900 West Valley Rd, Suite 301 |
Wayne, PA 19087-1830          | Direct Phone: (610)225-3560
========================================================================== 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Help with 'pathconvert', please!

Posted by Diane Holt <ho...@yahoo.com>.
--- Ken Gentle <j....@acm.org> wrote:
> You are seeing the same behavior that I am - the difference is that I 
> invoked ant from a directory on my "e:\" drive, and you from your "d:\" 
> drive.

Whoops -- sorry, read your initial mail a bit too quickly, and thought
your only problem was getting the drive letter to be "D" instead of "E".
Also didn't look at <pathconvert> all that closely, either -- turns out
it's a bit wigged out (or just not that well documented, since the
examples in the manual don't work correctly, either).

> It appears that the "map" element is being ignored for some reason,

The reason is, it doesn't match anything -- the drive letter has already
been prepended to your path, and the directory separator has already been
converted to DOS backslashes, so the pathname you're trying to "convert"
no longer starts with /prefix.

> and since the path looks like an absolute path (starts with a "/") the 
> "targetos=windows", it defaults to the current drive letter (e in my
> case, d in yours).

Actually, it looks like <path>/<pathelement> is what's putting the drive
letter on it and doing the dir separator conversion. If you assign your
path id to a property and <echo> that out, you'll see what it already
looks like before it ever gets to <pathconvert>.
 
> I expected pathconvert to strip the "/prefix" from 
> "/prefix/iplanet/ias6/ias/..." and replace it with a "D:\", with a 
> resulting classpath.project property defined as 
> "D:\iplanet\ias6\ias".  Isn't that the expected behavior?

You'd think so, huh? :)  But given what <path>/<pathelement> is doing, it
looks to me like the only way to end up with that as the result (when
you're running on Windows box) is to replace "D:\prefix" with "D:"
(assuming "D:" is your current drive).

Diane

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



__________________________________________________
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Pathconvert bug - was Re: Help with 'pathconvert', please!

Posted by Ken Gentle <j....@acm.org>.
This is a bug -  I can't get the examples from the pathconvert 
documentation to work either, at least on my Windows NT box.  I'm going to 
verify the same behavior on UNIX, then submit a bug.

         Ken


At 02:07 PM 12/11/2001 -0500, you wrote:
>You are seeing the same behavior that I am - the difference is that I 
>invoked ant from a directory on my "e:\" drive, and you from your "d:\" 
>drive.  It appears that the "map" element is being ignored for some 
>reason, and since the path looks like an absolute path (starts with a "/") 
>and the "targetos=windows", it defaults to the current drive letter (e in 
>my case, d in yours).
>
>I expected pathconvert to strip the "/prefix" from 
>"/prefix/iplanet/ias6/ias/..." and replace it with a "D:\", with a 
>resulting classpath.project property defined as 
>"D:\iplanet\ias6\ias".  Isn't that the expected behavior?
>
>Here's a simpler build file that may point out the issue a bit better:
>
><?xml version="1.0"?>
><project name="imf" default="generate_classpath" basedir=".">
>
>   <target name="generate_classpath" >
>     <pathconvert targetos="windows" property="classpath.project">
>           <path>
>             <pathelement location="/prefix/iplanet/iasclient.jar" />
>           </path>
>       <map from="/prefix" to="Z:\" />
>     </pathconvert>
>     <echo message="EXPECT: classpath.project=Z:\iplanet\iasclient.jar" />
>     <echo message="GOT:    classpath.project=${classpath.project}" />
>   </target>
>
></project>
>
>
>
>At 10:42 AM 12/11/2001 -0800, Diane Holt wrote:
>>I get:
>>$ ant -f pc.xml
>>Buildfile: pc.xml
>>
>>generate_classpath:
>>      [echo] BEFORE: PATH.PREFIX.TOKEN=/prefix
>>      [echo] BEFORE: home.iplanet=/prefix/iplanet/ias6/ias
>>      [echo] BEFORE: tools.windows.iplanet=D:\
>>      [echo] BEFORE: classpath.project=${classpath.project}
>>      [echo] AFTER:
>>classpath.project=D:\prefix\iplanet\ias\ias\classes\java\iasclient.jar}
>>
>>dump-info:
>>      [echo] ant.version=Ant version 1.4 compiled on September 3 2001
>>      [echo] ant.file=D:\cygwin\home\dianeh\work\ant\pc.xml
>>      [echo] java.vm.info=mixed mode
>>      [echo] java.vm.name=Java HotSpot(TM) Client VM
>>      [echo] java.vm.vendor=Sun Microsystems Inc.
>>      [echo] java.vm.version=1.3.0-C
>>      [echo] os.arch=x86
>>      [echo] os.name=Windows NT
>>      [echo] os.version=4.0
>>      [echo]
>>classpath.project=D:\prefix\iplanet\ias\ias\classes\java\iasclient.jar}
>>
>>BUILD SUCCESSFUL
>>
>>Total time: 0 seconds
>
>==========================================================================
>J. Kenneth Gentle (Ken)       | Phone: (610) 255-0361   FAX:(610) 255-0418
>Gentle Software, LLC          | Email: j.kenneth.gentle@acm.org
>==========================================================================
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>

==========================================================================
J. Kenneth Gentle (Ken)       | Phone: (610) 255-0361   FAX:(610) 255-0418
Gentle Software, LLC          | Email: j.kenneth.gentle@acm.org
==========================================================================


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Help with 'pathconvert', please!

Posted by Ken Gentle <j....@acm.org>.
You are seeing the same behavior that I am - the difference is that I 
invoked ant from a directory on my "e:\" drive, and you from your "d:\" 
drive.  It appears that the "map" element is being ignored for some reason, 
and since the path looks like an absolute path (starts with a "/") and the 
"targetos=windows", it defaults to the current drive letter (e in my case, 
d in yours).

I expected pathconvert to strip the "/prefix" from 
"/prefix/iplanet/ias6/ias/..." and replace it with a "D:\", with a 
resulting classpath.project property defined as 
"D:\iplanet\ias6\ias".  Isn't that the expected behavior?

Here's a simpler build file that may point out the issue a bit better:

<?xml version="1.0"?>
<project name="imf" default="generate_classpath" basedir=".">

   <target name="generate_classpath" >
     <pathconvert targetos="windows" property="classpath.project">
           <path>
             <pathelement location="/prefix/iplanet/iasclient.jar" />
           </path>
       <map from="/prefix" to="Z:\" />
     </pathconvert>
     <echo message="EXPECT: classpath.project=Z:\iplanet\iasclient.jar" />
     <echo message="GOT:    classpath.project=${classpath.project}" />
   </target>

</project>



At 10:42 AM 12/11/2001 -0800, Diane Holt wrote:
>I get:
>$ ant -f pc.xml
>Buildfile: pc.xml
>
>generate_classpath:
>      [echo] BEFORE: PATH.PREFIX.TOKEN=/prefix
>      [echo] BEFORE: home.iplanet=/prefix/iplanet/ias6/ias
>      [echo] BEFORE: tools.windows.iplanet=D:\
>      [echo] BEFORE: classpath.project=${classpath.project}
>      [echo] AFTER:
>classpath.project=D:\prefix\iplanet\ias\ias\classes\java\iasclient.jar}
>
>dump-info:
>      [echo] ant.version=Ant version 1.4 compiled on September 3 2001
>      [echo] ant.file=D:\cygwin\home\dianeh\work\ant\pc.xml
>      [echo] java.vm.info=mixed mode
>      [echo] java.vm.name=Java HotSpot(TM) Client VM
>      [echo] java.vm.vendor=Sun Microsystems Inc.
>      [echo] java.vm.version=1.3.0-C
>      [echo] os.arch=x86
>      [echo] os.name=Windows NT
>      [echo] os.version=4.0
>      [echo]
>classpath.project=D:\prefix\iplanet\ias\ias\classes\java\iasclient.jar}
>
>BUILD SUCCESSFUL
>
>Total time: 0 seconds

==========================================================================
J. Kenneth Gentle (Ken)       | Phone: (610) 255-0361   FAX:(610) 255-0418
Gentle Software, LLC          | Email: j.kenneth.gentle@acm.org
==========================================================================


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Help with 'pathconvert', please!

Posted by Diane Holt <ho...@yahoo.com>.
--- Ken Gentle <j....@acm.org> wrote:
> At 09:35 AM 12/11/2001 -0800, you wrote:
> >The build-file you included in this mail works for me -- are you
> >absolutely certain it's the exact same file you're running?
> 
> Er, um - yes, I am.

In that case I'm as stumped as you are as to why it works for me and not
for you. 

> You got something like
> 
>          "classpath.project=D:\iplanet\ias6\ias\iasclient.jar" ?!?

I get:
$ ant -f pc.xml
Buildfile: pc.xml

generate_classpath:
     [echo] BEFORE: PATH.PREFIX.TOKEN=/prefix
     [echo] BEFORE: home.iplanet=/prefix/iplanet/ias6/ias
     [echo] BEFORE: tools.windows.iplanet=D:\
     [echo] BEFORE: classpath.project=${classpath.project}
     [echo] AFTER: 
classpath.project=D:\prefix\iplanet\ias\ias\classes\java\iasclient.jar}

dump-info:
     [echo] ant.version=Ant version 1.4 compiled on September 3 2001
     [echo] ant.file=D:\cygwin\home\dianeh\work\ant\pc.xml
     [echo] java.vm.info=mixed mode
     [echo] java.vm.name=Java HotSpot(TM) Client VM
     [echo] java.vm.vendor=Sun Microsystems Inc.
     [echo] java.vm.version=1.3.0-C
     [echo] os.arch=x86
     [echo] os.name=Windows NT
     [echo] os.version=4.0
     [echo]
classpath.project=D:\prefix\iplanet\ias\ias\classes\java\iasclient.jar}

BUILD SUCCESSFUL

Total time: 0 seconds

> I am noticing an extraneous "}" in my output:
> 
>       [echo] 
> AFTER: 
> classpath.project=e:\prefix\iplanet\ias6\ias\classes\java\iasclient.jar}

That's just because you have it in your <pathelement>:
  <pathelement location="${home.iplanet}/classes/java/iasclient.jar}"/>

Diane

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



__________________________________________________
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Help with 'pathconvert', please!

Posted by Ken Gentle <j....@acm.org>.
At 09:35 AM 12/11/2001 -0800, you wrote:
>The build-file you included in this mail works for me -- are you
>absolutely certain it's the exact same file you're running?

Er, um - yes, I am.

You got something like

         "classpath.project=D:\iplanet\ias6\ias\iasclient.jar" ?!?

I'm stumped...  I've run it with Ant 1.4, Ant 1.4.1, JDK 1.3 and JDK 1.4b3, 
and I consistently get

         "classpath.project=e:\prefix\iplanet\ias6\ias\iasclient.jar"

I am noticing an extraneous "}" in my output:

      [echo] 
AFTER: 
classpath.project=e:\prefix\iplanet\ias6\ias\classes\java\iasclient.jar}
-------------------------------------------------------------------------------------------^

I open to any ideas as to how to proceed!

Thanks

         Ken

BTW, didn't you used to be on the JAMMING list a lot?  Doing JAM support?


>Diane
>
>=====
>(holtdl@yahoo.com)
>
>
>
>__________________________________________________
>Do You Yahoo!?
>Check out Yahoo! Shopping and Yahoo! Auctions for all of
>your unique holiday gifts! Buy at http://shopping.yahoo.com
>or bid at http://auctions.yahoo.com
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>

==========================================================================
J. Kenneth Gentle (Ken)       | Phone: (610) 255-0361   FAX:(610) 255-0418
Gentle Software, LLC          | Email: j.kenneth.gentle@acm.org
==========================================================================


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Help with 'pathconvert', please!

Posted by Diane Holt <ho...@yahoo.com>.
The build-file you included in this mail works for me -- are you
absolutely certain it's the exact same file you're running?

Diane

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



__________________________________________________
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>