ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peterson, Lance" <lpeter...@verticore.com>
Subject RE: Environment variables
Date Fri, 11 May 2001 21:48:26 GMT
We use property files.  Example:

<property file="build.properties" />

This imports build-time settings from a local file.  I set classpath,
java_home, source path settings in this file.  If I need to set environment
variables for a task, I use the task's attributes.  Or for exec tasks, I use
<env> nested attributes.  Example:

# set classpath, java_home, ejb_home properties
<property file="build.properties" />

<target name="stub">
  <exec executable="java2iiop">
    <env key="PATH" value="build.path" />
    <env key="CLASSPATH" value="build.classpath" />
    <arg value="-VBJclasspath" />
    <arg value="build.vbjclasspath" />
    <arg value="-root_dir" />
    <arg value="build.destdir" />
    <arg value="-compile" />
  </exec>
</target>

The <env> nested attribute allows me to set environment variables for
running the executable (java2iiop in this case).  This works for the exec
task, I don't know if there's a way to do it for other built-in tasks like
javac or jar.  But for those tasks, I can set classpath and compiler options
through task attributes.

Hope this helps,
Lance Peterson
Verticore Technologies Inc.

-----Original Message-----
From: Peter Vogel [mailto:pvogel@arsin.com]
Sent: Friday, May 11, 2001 2:57 PM
To: 'ant-user@jakarta.apache.org'
Subject: Environment variables


Hi Guys,

The more ant builds I look at, the more I see the common element
of a "setenv.bat" that sets common variables like CLASSPATH
and JAVA_HOME, etc.  

When I have architected builds in the past, I try to encapsulate
all of the environment settings into the makefile itself, with 
the makefile checking the user environment for overrides.  This
works with modern "make" systems like GnuMake because I can export
a Make variable to an environment variable (for all processes 
invoked by Make) using the export keyword.

I'd like to do the same in ant, it just offends my sensibilities 
to have to run a "SetEnv.bat" file first.  I'm aware of the "env"
nested directive (though it isn't in the documentation) for javac
and exec (where it is in the documentation).  But they aren't quite
what I'm looking for.  I'd like to define a property and specify that
it should be exported into the environment of all the subprocesses
spawned by ant.

Any suggestions?

Thanks,
-Peter

--
Peter A. Vogel
Manager+consultant, Configuration Management
Arsin Corporation, Professional Services
http://www.arsin.com  

Mime
View raw message