Title: RE: classpath conditional on OS

Tim,

Ant doesn't care whether you use "\" or "/" to seperate directories in paths, nor whether you use ":" or ";" to seperate paths in things like classpaths, even when they're mixed.  It essentially treats "/" or "\" and ":" or ";" as the same thing.

Using colons to indicate mount points might be a bit more interesting, I'm not sure if Ant handles the colon in "C:\" properly. (A little experimentation may tell you.) In my team we're always using relative paths, or paths relative to some locally-defined property. E.g., in build.xml, we've got:

 
 <property file="${user.home}/ant.properties"/>

and in "ant.properties" we've got:

 <property name="cvs-root" value="D:\cvs"/>

so that (later) in the build.xml we can write:

 <property name="classpath" value="${cvs-root}/libs/foo.jar:${cvs-root}/libs/bar.jar"/>

and that works no matter which operating system we're running the build on (asusming ant.properties is set up correctly).

 - rw

-----Original Message-----
From: Tim Veazey [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 10, 2001 12:24 PM
To: [EMAIL PROTECTED]
Subject: classpath conditional on OS


Hello,

I'm fairly new to ant.  I want to set some properties to be used in the
classpath according to the os that ant is running on.  Basically,
something like...

sunos =  (os.name.equals("SunOS")) ? true : false;
sep = (sunos) ? "/" : "\";
classroot = (sunos) ? sep + "root" : "R:" + sep;

Is there a way to do this?  I've looked at the <available ...> task, but
it's not clear yet how to use that towards my goal.  Thanks for your
help.

Oh, the justification is that we have a samba server running on a sun
station.  The projects classpath directories are exported to our PC
desktops using samba.  Thus, I want Ant to build on both the server and
the PC client.

--
* Tim Veazey - Software Engineer
* SupplyEdge, Inc.
* Phone:  (626) 585-2788 x113
*         (800) 733-3380 x113
* Fax     (626) 585-2785

Reply via email to