You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by James Sinnamon <Ja...@cs.anu.edu.au> on 2003/03/19 23:03:06 UTC

Access to Environment Variables other than ANT_HOME of CLASSPATH

Can environment variables be accessed from within a build.xml file?

The FAQs mentioned  ANT_HOME and CLASSPATH, but these seemed 
to only be used for the purposes of getting ant to run.

TIA

Best regards,

James
 
-- 
James Sinnamon
sinnamon@bigpond.net.au or sinnamon@cs.anu.edu.au
ph 0412 319669, 02 62842708(h), 02 61258182(w)

Re: Access to Environment Variables other than ANT_HOME of CLASSPATH

Posted by Sebastien Blanc <Se...@alcatel.com>.
Hi James !
see inserted.
seb.

James Sinnamon wrote:

> Seb,
>
> On Thu, 20 Mar 2003 09:05, you wrote:
> > <property environment="ejbenv" />
> >
> >  <fileset dir="${ejbenv.JAVA_HOME}/jre/lib">
> >          <include name="rt.jar" />
> > </fileset>
>
> If I set an environment variable such as in the following example:
>
>    export BASE_BOOTIMAGE_COMPILER=1
>    export BASE_RUNTIME_COMPILER=1
>    export NO_GC=1
>    export WITH_CLUSTER=1
>
> ... and then run ant,  will I be able to refer to these variables
> within build.xml?

yes. whatever environment variables are in the shell from witch u launch ANT
are gonna accessible via property environment.

> Basically I am hoping to be able to replace
> some scripts with a few ant targets which use the 'echo' task,
> and will be conditional on the setting of these variables.
> It would be easier to do so if I could do it without having to
> redefine  these environment variables in other files.
>
> > checkout the environment> in doc.
> > seb.
>
> Not sure where to find it.  I have looked at everthing I could find in the
> documentation which is  related to Environment variables in the
> Could you be more specific or show me the URL?
>

go to Core Tasks and then 'basename' or property':
http://ant.apache.org/manual/CoreTasks/basename.html
http://ant.apache.org/manual/CoreTasks/property.html

and - agree with Alexey - this is true that this can be done per
  <property file="${user.home}/.ant-global.properties"/>
which looks like a nicer java way of doing it, then getting rid of ur legacy
shell scripts using configuration variable.

"I am hoping to be able to replace
some scripts with a few ant targets which use the 'echo' task,
and will be conditional on the setting of these variables.
It would be easier to do so if I could do it without having to
redefine  these environment variables in other files."
-> not sure exactly wat u wanna do. can u expand ? are u trying to perform
something different in the script depending on a variable or to just to do
something different in the program u're trying to launch ?

seb.


Re: Access to Environment Variables other than ANT_HOME of CLASSPATH

Posted by James Sinnamon <Ja...@cs.anu.edu.au>.
Seb,

On Thu, 20 Mar 2003 09:05, you wrote:
> <property environment="ejbenv" />
>
>  <fileset dir="${ejbenv.JAVA_HOME}/jre/lib">
>          <include name="rt.jar" />
> </fileset>

If I set an environment variable such as in the following example:

   export BASE_BOOTIMAGE_COMPILER=1
   export BASE_RUNTIME_COMPILER=1
   export NO_GC=1
   export WITH_CLUSTER=1

... and then run ant,  will I be able to refer to these variables 
within build.xml?  Basically I am hoping to be able to replace
some scripts with a few ant targets which use the 'echo' task,
and will be conditional on the setting of these variables.
It would be easier to do so if I could do it without having to 
redefine  these environment variables in other files.

> checkout the environment> in doc.
> seb.

Not sure where to find it.  I have looked at everthing I could find in the 
documentation which is  related to Environment variables in the 
Could you be more specific or show me the URL?

>
> James Sinnamon wrote:
> > Can environment variables be accessed from within a build.xml file?
<snip/>

Thanks again.

regards,

James

Re: Access to Environment Variables other than ANT_HOME of CLASSPATH

Posted by Sebastien Blanc <Se...@alcatel.com>.
<property environment="ejbenv" />

 <fileset dir="${ejbenv.JAVA_HOME}/jre/lib">
         <include name="rt.jar" />
</fileset>

checkout the environment> in doc.
seb.

James Sinnamon wrote:

> Can environment variables be accessed from within a build.xml file?
>
> The FAQs mentioned  ANT_HOME and CLASSPATH, but these seemed
> to only be used for the purposes of getting ant to run.
>
> TIA
>
> Best regards,
>
> James
>
> --
> James Sinnamon
> sinnamon@bigpond.net.au or sinnamon@cs.anu.edu.au
> ph 0412 319669, 02 62842708(h), 02 61258182(w)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org