ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <dona...@apache.org>
Subject Re: userProperty flag in Property-Task
Date Thu, 11 Oct 2001 21:00:12 GMT
On Fri, 12 Oct 2001 00:46, Stefan Hardege wrote:
> hi,
>
> just wonder about the userProperty-flag in
> org.apache.tools.ant.taskdefs.Prooperty:
>
>     ...
>     protected boolean userProperty=false; // set read-only properties
>     ...
>
> but the only position in the code where
> this flag is checked is the following method:
>
>     ...
>     protected void addProperty(String n, String v) {
>         if( userProperty ) {
>             if (project.getUserProperty(n) == null) {
>                 project.setUserProperty(n, v);
>             } else {
>                 log("Override ignored for " + n, Project.MSG_VERBOSE);
>             }
>         } else {
>             if (project.getProperty(n) == null) {
>                 project.setProperty(n, v);
>             } else {
>                 log("Override ignored for " + n, Project.MSG_VERBOSE);
>             }
>         }
>     }
>     ...
>
>
> ...and i just cant figure out why the _if_ and the _else_ blocks are
> absolutly identic. 

naah - one saids set<em>User</em>Property and the other saids setProperty.

> is it a strange coding-style or a bug?

Not sure where the code comes from. It could be just stuff that was inherited 
as ant evolved or it may be that someone wanted to extend property to set 
user properties or something.

> if i have
> a look at the comment of the _userProperty_-flag it looks like this
> flag should indicate whether a property can be changed or is read-only
> but its just ignored ...

User properties overide all other properties and are similar to properties 
set on command line. However they are immutable, so once set are read-only. 
normal properties are also immutable. In a hacky sort of way you can overide 
normal properties by setting user properties but I would really not recomend 
that.

-- 
Cheers,

Pete

---------------------------------------------
 We shall not cease from exploration, and the 
  end of all our exploring will be to arrive 
 where we started and know the place for the 
        first time -- T.S. Eliot
---------------------------------------------

Mime
View raw message