ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik Hatcher" <jakarta-...@ehatchersolutions.com>
Subject Re: Please clarify a point about properties
Date Tue, 02 Apr 2002 22:11:56 GMT
----- Original Message -----
From: "Brian Murray" <brian.c.murray@vanderbilt.edu>
To: <ant-user@jakarta.apache.org>
Sent: Tuesday, April 02, 2002 10:53 AM
Subject: Please clarify a point about properties


> I'm trying to set up a precedence for setting properties as follows:
> command-line-->environment-->file.
> In searching the archives for some information about setting properties
> I saw the following statement which didn't seem accurate to me:

Yes, there is definitely a flaw with that example, thanks for pointing that
out.

How about this?

<property environment="env"/>
<property file="default.properties"/>

And use env.WHATEVER in your default.properties file as the property to set
there.  And internally use that property name internally to your build file
where needed and override from the command-line
using -Denv.WHATEVER=<whatever>.

I'm sure there are other ways to do this with a cleaner property name.  I
prefer not to use "env." properties internally and reassign them to
non-enviromental looking names - if you wanted to do that in this case you'd
have to resort to a temporary property to act as an intermediate
placeholder, I think.

    Erik

>
> >> I would like to define default properties in a
> >> property file and then "override" them from the
> >> environment. I have found two mechanisms for
> >> accomplishing this. The first is to use the
> >> <condition> clause, the second is to use "if"
> >> and "unless" attributes on targets that do <property>
> >> tasks.
> >>
> > <property environment="env"/>
> > <property name="my.desired.prop" value="${env.WHATEVER}"/>
> > <property file="default.properties"/>
> >
> > then define my.desired.prop in default.properties.  It will be
> "overridden"
> > (which is a weird term, when its actually being set first instead of
> being
> > overwritten).
>
>
> Now I'm fuzzy on the whole property thing, but it seems like
>   <property name="my.desired.prop" value="${env.WHATEVER}"/>
> Would set "my.desired.prop" to the STRING "${env.WHATEVER}" if WHATEVER
> was not a defined environment variable.  Therefore, any attempt to set
> "my.desired.prop" in the "default.properties" file would fail because
> "my.desired.prop" would already be set.
>
> Am I off base?
>
> Brian Murray
> Vanderbilt University
>
> Brian Murray
> Vanderbilt University
>
>
> --
> To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message