ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Haas" <>
Subject Re: Path & dir separators (was Re: Ant Principles)
Date Wed, 19 Apr 2000 19:31:25 GMT

The Path object has been mentioned several times during this intersting
discussion. I did it for the JUnit task (yes the patch will follow), to
solve some issues discussed here.

The Problems
1) Pathes and files may not only be defined in a build file but also on the
commandline. The value given on the commandline maybe an enviroment variable
or the output of another program or shell scripts. These definitions will be
specific to the platform ant is executed. If you use properties in your
build file for seme files or pathes, they nay be defined according the
current platform and not to any guideline established for ant build files.
Also concatenating a predefined path in the environment and a path defined
in the build file will always result in a mix of /, \, : and ; if you do
work on several platforms.
And I do not want to preprocess pathes or filed defined on the commandline,
as I would be back to my shell scripts, where I started.

2) From my work with the JUnit task the problem is defining a path and not
as single file or directory. The file or directory can be passed as is to an
instance of which accepts / and \ and probably whatever is used
on your platform (VMS on OS/390 were mentioned). The problem is splitting a
path into its elements, which are used to create File objects.

Let files be interpreted by the File object and do something smart about

The Path object:
The Path object has been created with all these issues in mind:

<somepath definition="${}:/some/path/classes:/other/file.jar">
    <element location="/path/to/classes"/>
    <element location="/path/to/file.jar"/>

"location" is used as is the create instances of  File. Location is split
into elements (being smart about drive letters), which are used to create
File objects. If you want to be more restrictive replace "defintion" by
"lazydefinition" and "definitionaccordingtotheplatform". Do the same for
location (Note: Naming is not what I am best at).

- pass files and directories as is to the File object and let Java handle
the issues.
- be msart about pathes (list of files or directories).
- do not restrict the user.

- tom

If interested, have a look at the Path object provided in the JUnit Patch in
another mail following this one.

View raw message