Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to understant "pathconvert"?

 
Tom John
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have following code:

--------------------------------
<project name="Pegasus"default="compile" basedir=".">
...
<pathconverttargetos="windows"
property="win.basedir">
<path>
<pathelement path="${basedir}" />
</path>
<map from="${path.root}" to=""/>
</pathconvert>
....
-------------------------------------

1) Here I don't know what's "${basedir}"?
2) Seems like "${basedir}" including "${path.root}"?? (${path.root} means "/vobs" in a 3rd party's property file)
3) How can I understand this whole code?

Thanks in advance!
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
basedir="." means set the basedir property to the directory containing your build.xml file at the point when you started Ant. Usually, you keep that file in the root of the project directory, so the basedir is the project directory.

In most cases, Java will accept filepaths normalized to the Unix format - meaning that you can (and should) use forward slashes in the directory separators. However, if you need a filepath in the native form of an OS (Windows, Unix or Mac) - say with the Windows backslashes - then you use the pathconvert feature to do that for you.
 
Tom John
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim, thank you very much!

I'm still confused by the second question.

It tell me that if ${basedir}is begging with ${path.root}, then it will be replaced by "". Right?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've got me confused. "path.root" isn't one of the standard Ant or Java system properties - as I read it, you're saying that there's a third-party properties file that defines path.root.

In the example you've shown, the source for the path translation is $path.root. If path.root was defined as an absolute pathname, Ant will use that absolute pathname. If path.root was defined as a relative pathname, then the path will be relative to $basedir, as are all other relative path references in an Ant task. So for relative paths, from="${path.root}" and from="${basedir}/$(path.root}" would be equivalent.


I left off the curly brackets because I was too lazy to type them.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic