You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Charles Mégnin <ch...@theblueplanet.org> on 2001/08/12 04:33:13 UTC

environment variable

Would someone have an example of how an environment
variable is used in a build ? I can't seem to make any sense
of the doc on property. Thanks in advance.
Charles


Re: environment variable

Posted by Erik Hatcher <er...@earthlink.net>.
Charles,

I'm not sure what you mean by "include in the target".   Please elaborate on
what you are trying to accomplish.

You can do stuff like this inside a target:
<echo message="env.JAVA_HOME = ${env.JAVA_HOME}"/>

Also, I'd refrain from using properties beginning with "java." as there are
many that get pre-defined with that prefix in the System properties that Ant
picks up and provides for you automatically and you might collide if you
aren't careful (and Ant properties are immutable, so whoever sets it first
wins!).

    Erik

----- Original Message -----
From: "Charles Mégnin" <ch...@theblueplanet.org>
To: <an...@jakarta.apache.org>
Sent: Saturday, August 11, 2001 8:09 PM
Subject: Re: environment variable


> Thanks Erik but the source of my confusion is with
> using an environment variable in a build such as:
>
> <property environment="env"/>
>
> (...)
>
> <target name="build" depends="init">
>     <mkdir dir="${java.build}"/>
>     <javac srcdir="${java.source}" destdir="${java.build}">
>     </javac>
>  </target>
>
> How do I include say ${env.JAVA_HOME}  in the target ?
> Charles
>
>
> Erik Hatcher wrote:
>
> > >From http://www.jguru.com/forums/view.jsp?EID=474002 :
> >
> > <property environment="env"/>
> >
> > provides all environment variables as Ant properties prefixed by "env.".
For
> > example, CLASSPATH would be accessible in Ant as ${env.CLASSPATH}.
> >
> > Although using CLASSPATH is just illustrative, since you could use
> > ${java.class.path} instead - but the same example applies for any other
> > environment variables you wish to access.
> >
> >     Erik
> >
> > ----- Original Message -----
> > From: "Charles Mégnin" <ch...@theblueplanet.org>
> > To: <an...@jakarta.apache.org>
> > Sent: Saturday, August 11, 2001 7:33 PM
> > Subject: environment variable
> >
> > > Would someone have an example of how an environment
> > > variable is used in a build ? I can't seem to make any sense
> > > of the doc on property. Thanks in advance.
> > > Charles
> > >
>


Re: environment variable

Posted by Charles Mégnin <ch...@theblueplanet.org>.
Thanks Erik but the source of my confusion is with
using an environment variable in a build such as:

<property environment="env"/>

(...)

<target name="build" depends="init">
    <mkdir dir="${java.build}"/>
    <javac srcdir="${java.source}" destdir="${java.build}">
    </javac>
 </target>

How do I include say ${env.JAVA_HOME}  in the target ?
Charles


Erik Hatcher wrote:

> >From http://www.jguru.com/forums/view.jsp?EID=474002 :
>
> <property environment="env"/>
>
> provides all environment variables as Ant properties prefixed by "env.". For
> example, CLASSPATH would be accessible in Ant as ${env.CLASSPATH}.
>
> Although using CLASSPATH is just illustrative, since you could use
> ${java.class.path} instead - but the same example applies for any other
> environment variables you wish to access.
>
>     Erik
>
> ----- Original Message -----
> From: "Charles Mégnin" <ch...@theblueplanet.org>
> To: <an...@jakarta.apache.org>
> Sent: Saturday, August 11, 2001 7:33 PM
> Subject: environment variable
>
> > Would someone have an example of how an environment
> > variable is used in a build ? I can't seem to make any sense
> > of the doc on property. Thanks in advance.
> > Charles
> >


Re: environment variable

Posted by Erik Hatcher <er...@earthlink.net>.
>From http://www.jguru.com/forums/view.jsp?EID=474002 :

<property environment="env"/>


provides all environment variables as Ant properties prefixed by "env.". For
example, CLASSPATH would be accessible in Ant as ${env.CLASSPATH}.

Although using CLASSPATH is just illustrative, since you could use
${java.class.path} instead - but the same example applies for any other
environment variables you wish to access.

    Erik


----- Original Message -----
From: "Charles Mégnin" <ch...@theblueplanet.org>
To: <an...@jakarta.apache.org>
Sent: Saturday, August 11, 2001 7:33 PM
Subject: environment variable


> Would someone have an example of how an environment
> variable is used in a build ? I can't seem to make any sense
> of the doc on property. Thanks in advance.
> Charles
>