ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: setting environment variables using ant
Date Wed, 08 May 2002 19:35:03 GMT
A child process (the Java VM running ANT) cannot modify the environment of
its parent process (the DOS command line interpreter, cmd.exe). Even script
cannot do what you ask on Unix when you 'run' them, only when you 'source'
them (must be compatible with the shell currently running). DOS .bat files
are always 'sourced' by default, so they modify the current DOS session,
unless the .bat calls setlocal before modifying its own environment.

So in short, using ANT as a kind of scripting replacement for .bat files is
not possible. All is not lost though, as Erik pointed out... If you define
an ANT target to run your java program, you can easily define with ANT the
classpath it should use. But then again, ANT is not an application launcher
either, although it can do it (hangs around, and filters the output though,
since the 'start and forget' capability of <exec> doesn't seem to make it
into ANT)...

Oh well, I guess this is not really helpful after all. --DDs

-----Original Message-----
From: raghavendra@hss.hns.com [mailto:raghavendra@hss.hns.com] 
Sent: Wednesday, May 08, 2002 9:10 AM
To: ant-user@jakarta.apache.org
Subject: setting environment variables using ant




Hi,
I have been using ant for a month or so and find it very useful and cool.
I am not able to solve the following problem for a couple of days...

I want to set Environment variables from ANT. Say ... I want to run a java
program. The usage should be

e:\> ant setclasspath     (setclasspath is the target which should set the
classpath appropriately)

This target should set the classpath variable to some string in the
build.xml (it could be a variable/property). Next I should be able to do
the following

e:\> java MyProgram    (classpath should be set to access MyProgram in the
previous step).

I am sure guys out here must have used ant extensively. Would be glad to
receive suggestions on doing this.

Thanks.

Regards,
Raghu



--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message