ant-dev mailing list archives

Site index · List index
Message view
Top
From Michael Smith <mich...@sneakerlabs.com>
Subject Re: Path & dir separators (was Re: Ant Principles)
Date Wed, 19 Apr 2000 22:44:38 GMT
Mariusz Nowostawski wrote:
> sounds all right to me as well.
> However, it is not appealing to me to type
>    dirseparator="\" pathseparator=";"    and
>    dirseparator="/" pathseparator=":"    and
>      others ....
> all over again in milions of places.

well, hopefully, you won't be relying on various conventions all over your
build file.  I would think that a majority of the separators will be the
same.  That way, you only need to explicitly put in those that differ from
the default, which should really only ever occur with absolute paths.

> _If_ the OS name issue has been resolved, the OS could have associated
> default separators and it could be more compact to use:
>
>    <src>
>      <path os="win" definition="c:\foo\bar" />
>      <path os="unix" definition="/usr/local/foo/bar" />
>    </src>
>
> Thus "os" could be really not an indication of OS, but indication of the
> family of conventions for filesystem path expressions, i.e. unix-like,
> windows-like, macos-like, vms-like, etc.  Each OS has than associated
> filesystem path expression convention, and linux-solaris, linux-i686, and
> hpux for example are all using unix-like filesystem path expression

The use of "os" here is a bit awkward.  As you say, "'os' could be really
not an indication of OS, but indication of the family of conventions for
filesystem path expressions."  Because of this, I would suggest using the
attribute "separators" instead of "os".  Thus replacing dirseparator and
pathseparator with one attribute "separators" that specifies the convention
that is used (win, mac, unix, vms, etc.).

> conventions. With some luck ;o) we would need to define only some
> mappings (say windows, mac, vms), and for "unknown" assume unix-like
> conventions.

"unknown" should not default to unix-like; it should default to the platform
that you're running on.  That is, the directory separator should be
retrieved from File.separator and the path separator should be retrieved
from File.pathSeparator.

> Could be done in the property definition or in some standard property
> file for ant. Would be nice also to define default convention for build
> file, to skip reapeating for example
>   os="unix"
> all over again, for relative paths for example.

The default is specified as an attribute of the project, or, if no default
is specified for the project, then the local platform's values are used as
defaults.

E.g.  to have all of them default to unix-like separators, you would use:

<project separators="unix" ... >
...
<src>
<path definition="../classes"/>
<!-- this one uses project default "unix" -->

<path separators="win" definition="C:\foo\bar"/>
<path separators="mac" definition="baz:foo:bar"/>

<path definition="/usr/local/foo/bar"/>
<!-- this one uses project default "unix" -->
</src>
...
</project>

With the renamed "separators," you could still use the "os" attribute to
indicate which paths to exclude/include on different platforms.  Again, this
inclusion/exclusion is done the same way that exec determines whether a
certain command is executed (and I don't know how that's done, nor have I

<project separators="unix" ... >
...
<src>
<path definition="../classes"/>
<path os="win" separators="win" definition="C:\foo\bar"/>
<path os="mac" separators="mac" definition="baz:foo:bar"/>
<path os="unix" definition="/usr/local/foo/bar"/>
</src>
...
</project>

Here, the path will be constructed with exactly two elements on each of the
windows, mac, and unix windows platforms:
..\classes;c:\foo\bar
..:classes;baz:foo:bar   <-- or whatever the path separator is on a mac
../classes:/usr/local/foo/bar

Regards,
Michael
--
michael@sneakerlabs.com
http://www.sneakerlabs.com


Mime
View raw message