ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conor MacNeill" <co...@cortexebusiness.com.au>
Subject RE: Platform independent classpath in build.xml?
Date Thu, 01 Jun 2000 00:33:54 GMT
Brill,

> > I don't think "," is the standard ant separator. Where does it say this?
>
> It doesn't say it anywhere, but its all over Ant... call it the "unwritten
> rule"...
>

Easily broken then ... :-). In fact the current spec proposal (see File
Naming Conventions) states that in the build file the path separator is ':'
and the directory separator is '/'. The ';' and '\' characters are
alternatives.

> > Its actually better than you realise. As it stands ant will
> accept a path
> > specification with either Windows or Unix standard path separators and
> > translate to the native platform's representation. This makes ant very
> > accepting. In general I try to stick to the Unix style separators in my
> > build files even though I work mostly on NT.
>
> The trouble with it is that we assume that we're going to get a unix or a
> windows path separator... what happenes on another OS, such as JOS
> (www.jos.org)... does anyone know what will happen on an Amega? (not that
> amega is likely to ever implement a recent JDK, but the concept is sound).
> My point is, that a particular token separator is used everywhere in ant,
> except in a classpath...
>

I don't think we can get universal agreement on a path separators over all
platforms. The current behaviour accepts Windows and Unix style separators
and tries and be "accommodating". For interchange of build files between
those two families of platforms, that is pretty cool. Nevertheless, I would
be happy to fix the separators within build files to be ':' and '/'. The
build files would be platform independent and it would be up to the ant core
to cater for the platform differences. I would still want DOS style absolute
paths to be supported when running on systems which support such paths
(C:/blah).

Previously my position was that I had wanted ant to be useable by people
using their native platform conventions. If a person has to provide a
classpath and they are used to providing it in a particular way, I wanted
ant to accept that. The resulting build files would still have been cross
platform, provided no absolute paths had been used. My view was based on
Unix and Windows style platforms and I guess that view may preclude other
platforms.


> There is also no reason that the system classpath can't work in
> conjunction
> with an "ant classpath"... once the ant classpath is converted to a native
> path at runtime, the system classpath could be appended if desired.
>

Not sure what you are getting at here.

>
> Looks like it would work, but you have hard coded the path separator chars
> in some places... I think you can do the same thing without doing
> that... in
> fact I have done that very thing... here is a rough method that will be
> something like what I did, although in a slightly different context...
> I don't think it will compile without a little work (I didn't try
> it anyway)
> but you can see what I'm talking about.
>
> public static final File[] tokenizePaths(String working) {
> 	ArrayList filelist = new ArrayList();
> 	if (working != null) {
> 		if (working.indexOf(File.pathSeparator) > -1) {
> 			// this is a series of paths.
> 			// we need to tokenize the string.
> 			if (!working.endsWith(File.pathSeparator)) {
> 				// append a token, for the tokenizer.
> 				working = working + File.pathSeparator;
> 			}
> 			StringTokenizer tok = new
> StringTokenizer(working, File.pathSeparator);
> 			while (tok.hasMoreTokens()) {
> 				filelist.add(new File((String)
> tok.nextToken()));
> 			}
> 		} else {
> 			// this is a single path.
> 			File file = new File(working);
> 			filelist.add(file);
> 		}
> 	}
> 	return (File[]) filelist.toArray();
> }
>
> As you can see, at no point do I use a hard-coded path separator... and
> because of that, this method should work on *any* java compliant OS,
> regardless of what unique path separators it uses...

Your code is platform independent but it makes all build files platform
dependent. A build file which works on one platform will not work on another
with a different separator. One of the major goals of ant is to allow build
files to be platform independent.

I suggest you have a read of the core.html document in the spec directory.
It discusses some of these issues.

Cheers
Conor


Mime
View raw message