ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Murdoch" <adammurd...@yahoo.com>
Subject RE: Environment variables
Date Tue, 10 Oct 2000 22:10:18 GMT

Hi,


The exec task allows you to specify the environment variables for the child
process.  You do this using nested <env> elements:

<exec ... >
	<env key="SSDIR" value="some value"/>
</exec>

Check out the documentation for the exec task for more info on using <env>.
You should note that if you specify any environment variables in the exec
task, then only these variables are passed to the child process.  The child
process will not inherit any of the parent process' (ie ant) environment in
this case.

I have a feeling that support for the <env> element was added after ant 1.1
as released, so you may have to upgrade to a nightly build to use this.

If you can't upgrade, then here's a couple of suggestions:

1. Write a wrapper script that your build script calls using <exec>, passing
the value for SSDIR as one of its arguments.  Check out antRun.bat for an
example of a similar sort of script.

2. Write your own task that calls the version of Runtime.exec() that lets
you pass in the environment for the child process (you might be able to use
the org.apache.tools.ant.taskdefs.Execute class to help you - but it might
not be available in ant 1.1).


Adam

> -----Original Message-----
> From: Dan MacKay [mailto:dan.mackay@kingston.hummingbird.com]
> Sent: Wednesday, 11 October 2000 5:43 AM
> To: ant-user@jakarta.apache.org
> Subject: Environment variables
>
>
> Hi all,
>
> I am a relative new user to ant and have the following question. Is it
> possible to manipulate DOS session environment variables from
> inside of ant.
> The problem I am having is setting up MS Source Safe environment variable
> SSDIR. This is would be to enable me to hand in the SS database that I
> wished to use for for a build as a property, change (if
> necessary) the SSDIR
> variable and then call use a target such as:
>
>    <target name="getSource" depends="prepare">
>       <exec command="ss cp ${SSProject}"/>
>       <exec command="ss.exe get
> ${SSProject} -Y${SSUserName} -R -I- -O- -GL${buildDir}"/>
>    </target>
>
> This snippet works if I have manually set (either permanently via the
> control panet or use a batch file external to the ant process) the SSDIR
> prior to calling ant. I surmize that I cannot use something such as:
>
> <exec command="set SSDIR=\\Sourcesafe2\70\">
>
> because this would only set SSDIR for the currently executing process that
> is created by a call to exec. Any hints on how I could accomplish
> this from
> within the buildfile?
>
> Thanks,
> Dan


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


Mime
View raw message