ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conor MacNeill" <>
Subject RE: Platform independent classpath in build.xml?
Date Mon, 05 Jun 2000 13:57:49 GMT
> Sure... that would be a good feature, but why wouldn't you have an Ant way
> to represent the classpath?

We do. It uses ':' or ':' as the path separator and '/' or '\' as the file

> That's exactly my point... if you standardize the path separator, then the
> build file become platform independent. As it is now, you must use a
> separator from unix or windows... just because they are
> interchangeable does
> not make them platform independent. The fact that unix and windows
> separators are interchangeable at all, is really a convenience
> for those who
> are used to using a particular separator, but its not to someone who is
> familiar with an entirely different separator.

We have standardised the path separator as being either ':' or ';'. It is
platform independent because the translatePath method of Project will
replace either of these characters with File.pathSeparator, which is the
path separator of the native platform. The fact that the choice matches the
separators on some common platforms, while not unintentional, does not make
that choice platform dependent.

> Right... ok... so basically you say that ":" is the ant path separator...
> this is what I want to hear... however my point still stands that it might
> not be obvious to someone who has never seen a unix style path
> separator...
> like myself (who does use unix btw) they are first going to try and use a
> comma, because most other lists in Ant use them. Its a natural assumption.

Fair point, but it could be addressed with appropriate documentation.

Actually I once proposed a patch for multiple source dirs using commas as a
separator. I can paraphrase the reactions as
1. comma is a valid filename character on some platforms (RCS files)
2. all delimited strings are bad and we should use XML element structuring
3. It should have been ':'

In particular, Thomas' classpath structuring falls into the second camp. I
think that is useful but I also find delimited strings concise and natural.
The full XML expression can be a little verbose.

The second advantage of delimited strings stems from the fact that they can
be passed in from the external environment as ant property definitions. It
is here that the choice of delimiters to match those of Unix and Windows is
useful. On those platforms, classpaths defined in the native format can then
be passed directly into ant and will work as expected.

For example, say we are using JUnit to run tests. We define an environment
variable with the JUnit classpath. It is used to run JUnit, so must be
expressed in the native platform conventions. On Unix it will be a :/ style
path and on NT a ;\ style path. Now we also want to use ant to build the
test classes. We pass the JUnit classpath as an ant property define. IN the
build file, we append some extra directories to the given classpath. Since
we have only one, cross-platform, build file we choose to use :/ notation.
When running under NT the resulting classpath has both :/ and ;\ elements.
The current delimiter choice allows such constructs to work. Its not
essential, but it is a nice to have.



View raw message