ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Li, Jerry" <>
Subject RE: retrieve env vars thru ant
Date Fri, 19 Oct 2001 16:03:08 GMT
I am working on Windows 2000. Below is my implementation to get an system
env from ant.

<project default="compile" basedir=".">
=================================================================== -->
	<!-- Initialization target
=================================================================== -->
	<target name="init">
		<property environment="ENV"/>
		<property name="ANTCONF_DIR" value="${ENV.WORK_DIR}/src"/>
		<property name="SRC" value="${user.dir}"/>
=================================================================== -->
	<!-- Compiles the source directory
=================================================================== -->
	<target name="compile" depends="init">
		<ant antfile="${ANTCONF_DIR}/build_cfg.xml"


-----Original Message-----
From: Phil Surette []
Sent: Thursday, October 18, 2001 11:41 PM
Subject: Re: retrieve env vars thru ant

Since there is no way to get at environment variables from
java, I was stunned to see that you could do it and ran
off to create a test script. 

...catch is it doesn't work under Windows 2000. 

<project default='echoenv'>
    <property environment='env'/>
    <property name="test" value="hello whirled"/>

    <target name='echoenv'>
        <echo>path = ${env.PATH}
            test = ${test}</echo>

Buildfile: build.xml

     [echo] path = ${env.PATH}
            test = hello whirled


Total time: 2 seconds

I guess Win2000 is not one of the 'select' platforms
that the task works under... 

Steve Loughran wrote:
> ----- Original Message -----
> From: "Erik Hatcher" <>
> To: <>
> Sent: Thursday, October 18, 2001 09:06
> Subject: Re: retrieve env vars thru ant
> > As for JAVA_HOME, you can access it already with ${java.home}.
> > it'll likely have "jre" appended to what the environment variable
> > says.)
> I am not sure they are the same. JAVA_HOME usually points to the JDK base,
> but java.home can refer to wherever the current JRE is, right? So if you
> have the JDK but run off a JRE under Program Files then java.home can be a
> long way from JAVA_HOME
> > For other environment variables, have a look at <property
> environment=".....
> > />
> >
> that's what I use.

Note:  The information contained in this message may be privileged and
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, or an employee or agent responsible for
delivering this message to the intended recipient, you are hereby notified
that any dissemination, distribution or copying of this communication is
strictly prohibited. If you have received this communication in error,
please notify us immediately by replying to the message and deleting it from
your computer. Thank you. 

View raw message