ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject Re: Controling the environment for exec tasks
Date Tue, 18 Jul 2000 07:05:49 GMT
>>>>> "JC" == Julien Couvreur <> writes:

 JC> Hi, First, thanks to all you guys answering ! That's really
 JC> great.

 JC> Now,

 >>> Yes, that'd be the way to go, and maybe if value was omitted use
 >>> System.getenv to get the current value?

 JC> Are the current values not passed by default.

I thought they wouldn't if you specify the environment explicitly,
i.e. use one of the two argument Runtime.exec methods. So I went on
and tried it and:

Exception in thread "main" java.lang.Error: getenv no longer supported, use properties and
-D instead: SSH_AGENT

on System.getenv("SSH_AGENT")

so there is nothing much we could do anyway - seems like they start
adding meaning to the deprecation tags.

 JC> Also, could somebody give me (or us) a hint why antRun is
 JC> involved ?

You cannot change the working directory of a process in Java - but we
do have a dir attribute in Exec. The script just changes the directory
and calls the intended program after that.

 JC> About the createXXX and addXXX : 

 JC> - what is the difference between create and add.

If you use createXXX, it's the responsibility of the task to create an
instance of the "nested" class. Using addXXX this will be done from
the IntrospectionHelper. That's all.

Sometimes it's impossible to do the right thing from outside (if the
class returned doesn't have a public constructor or you don't want to
create a new instance every time - see Path for example), then
createXXX is the way to go. Sometimes there is no special magic
necessary (I envision setting environment variables to be such a case)
so you can happily stick with addXXX.

 JC> - why not put a small example with createXXX, addXXX, and Class
 JC> ReturnObject ?

If I had time ...

 JC> - what constraints is there on the ReturnObject ?

None if you use the createXXX methods. To be eligible for the addXXX
method, the class must have a public no arg constructor.


View raw message