You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by jo...@gmail.com on 2006/06/06 11:41:21 UTC
Using and checking an environment variable?
I want to distribute the build.xml file with an application and therefore
not include any paths to software the application depends on. Ideally I
would want to take this from an environment variable and show an error
message if the environment variable is not set.
Currently I set a property like this:
<property name="sw.home" location="${env.THE_VARIABLE}" />
and later use sw.home wherever needed.
I cannot figure out how to best provide a default here or even better, abort
with a descriptive error message if the environment variable is not set.
Re: Using and checking an environment variable?
Posted by Vincent <vi...@gmail.com>.
You can also try the following
<if>
<not>
<isset property="env" />
</not>
<then>
<fail message="Please set the env!" />
</then>
</if>
greetings
Vincent
On 6/6/06, Ben Stringer <be...@burbong.com> wrote:
> On Tue, 2006-06-06 at 11:41 +0200, johann.petrak@gmail.com wrote:
> > I want to distribute the build.xml file with an application and therefore
> > not include any paths to software the application depends on. Ideally I
> > would want to take this from an environment variable and show an error
> > message if the environment variable is not set.
> >
> > Currently I set a property like this:
> > <property name="sw.home" location="${env.THE_VARIABLE}" />
> > and later use sw.home wherever needed.
> >
> > I cannot figure out how to best provide a default here or even better, abort
> > with a descriptive error message if the environment variable is not set.
>
> <property environment="env"/>
> <fail message="MY_VAR not set. See README.txt" unless="env.MY_VAR"/>
>
> Cheers, Ben
>
> Ben Stringer ===== ben@burbong.com
> ==================================
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Using and checking an environment variable?
Posted by Ben Stringer <be...@burbong.com>.
On Tue, 2006-06-06 at 11:41 +0200, johann.petrak@gmail.com wrote:
> I want to distribute the build.xml file with an application and therefore
> not include any paths to software the application depends on. Ideally I
> would want to take this from an environment variable and show an error
> message if the environment variable is not set.
>
> Currently I set a property like this:
> <property name="sw.home" location="${env.THE_VARIABLE}" />
> and later use sw.home wherever needed.
>
> I cannot figure out how to best provide a default here or even better, abort
> with a descriptive error message if the environment variable is not set.
<property environment="env"/>
<fail message="MY_VAR not set. See README.txt" unless="env.MY_VAR"/>
Cheers, Ben
Ben Stringer ===== ben@burbong.com
==================================
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org