ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Castrianni <>
Subject RE: setup environment for java task
Date Fri, 13 Feb 2009 08:36:20 GMT
Thanks for the suggestion, but here is my problem:

1. These batch files are used at runtime from an end user after installing the product with
an installer.
2. Therefore, these batch files cannot be converted to ANT as that would duplicate the logic
and could get out of sync
3. I am trying to recreate an end user's runtime environment with ANT so that I can launch
our application or run unit tests with the same environment which is why I want to execute
those same batch files
4. executing each batch file in an exec task only affects the process spawned by the exec
task and is not remembered from one batch file to the next so when I finally launch my java
class, that environment from the batch files is already gone, I think

Shawn Castrianni

-----Original Message-----
From: Knuplesch, Juergen []
Sent: Friday, February 13, 2009 2:05 AM
To: Ant Users List
Subject: AW: setup environment for java task


I would translate the "bat" files to ANT-Tasks.
This is a lot of work, but than your Antfile can decide what bat-jobs you run and when.

Another way is to run the bat-files itself inside Ant using the exec-task, which is a bit
tricky to handle.

To be honest: I dont like Batchfiles, so I would prefer "translating" the stuff to Ant, so
that I have the control out of Ant.
But maybe, if you need the Batchfiles as well, then you produce redundancy, if you translate
it to Ant.



J├╝rgen Knuplesch
-----Urspr├╝ngliche Nachricht-----
Von: Shawn Castrianni []
Gesendet: Freitag, 13. Februar 2009 08:27
An: 'Ant Users List'
Betreff: setup environment for java task

Let's say I have a series of setupEnv.bat files in my source repository that I need to execute
as part of setting up my runtime environment before executing my java code with the java task.
 I don't see an elegant way of doing this.  I could execute these bat files as part of my
build.bat before invoking ant itself.  However, I don't like this approach as it would interfere
with my build environment.  I only want it to affect my runtime environment when I launch
java code from my build.xml.  For example, my "build.bat compile" command should not invoke
the setupEnv.bat files, but my "build.bat launch" command should.  I don't want to start writing
a lot of logic in my simple build.bat script which just launches ant to detect what target
is being run to know whether to invoke the setupEnv.bat files.  I was hoping for something
more elegant inside ANT itself.  The java task already provides a way to pass in environment
variables, but I don't see how I could have it execute some bat files first to setup the environment.

Does anybody know of an elegant way of doing this or some 3rd party ant plugin that can do

I don't even know if it is possible in java.  You would have to somehow invoke a separate
process and then feed it commands to run (like executing batch files) to setup its environment,
and then pass it the JVM command line to finally invoke the java class.

Shawn Castrianni

This e-mail, including any attached files, may contain confidential and privileged information
for the sole use of the intended recipient.  Any review, use, distribution, or disclosure
by others is strictly prohibited.  If you are not the intended recipient (or authorized to
receive information for the intended recipient), please contact the sender by reply e-mail
and delete all copies of this message.

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message