ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Vogel <pvo...@arsin.com>
Subject RE: Environment variables
Date Fri, 11 May 2001 23:16:09 GMT
Yeah, I knew I could do what you indicate below (though I do appreciate the
syntax sample) 
but It seems a little ridiculous to have to copy all these "env" elements
into EVERY task
(granted, there are fewer tasks in ant than there would be in make) to make
things work.  I'd
like to be able to do something like this:
 
<target name="init">
<tstamp/>
<env id="build.env">
   <import env> <!-- get whole system environment -->
   <key="PATH" value="build.path"> <!-- override PATH -->
   <key="JAVA_HOME" value="c:/jdk1."> 
   <key="WL_HOME" value="c:/weblogic5.1">
</env>
</target>
 
And then be able to do this:
 
<target name="compile" depends="init">
    <javac srcdir="${src}" destdir="${dest}" env="build.env"/>
</target>
 
For now, I guess I'll muddle along...
 
-Peter

-----Original Message-----
From: Peterson, Lance [mailto:lpeterson@verticore.com]
Sent: Friday, May 11, 2001 2:48 PM
To: 'ant-user@jakarta.apache.org'
Subject: RE: Environment variables



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 <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 <http://www.arsin.com>   


Mime
View raw message