You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Peter Donald <do...@apache.org> on 2001/06/17 09:11:40 UTC

[ant2] Propertys and strategies to deal with them

Hi,

I was just wondering on how people think we should handle properties. 
Specifically there is a few interacting features that have to be decided 
before any property system could be built into Ant2. These are

1. How do we scope properties?
2. Are properties mutable or immutable?
3. Is there a difference between passed in parameters (via ant.properties or 
CLI) and build file specified properties?
4. Should we allow declaration of variables without assignment?

By (1) I mean, are proeprties defined inside targets (or ContainerTasks) 
local to that target (or ContainerTask). There would still be some mechanism 
to set properties of "higher" level scopes but in general properties would be 
target specific.

By (2) I am asking whether we allow properties to be altered after being set 
once.

(4) is not something that has been discussed much but it was something 
mentioned in requirements gathering phase but never really explored. 
Essentially what this means is that you could "declare" a variable at top 
level of project scope but set it at lower level scopes. 

>From my experiements I like the idea of scoping but found it impractical 
unless something like (4) is implemented (or some attribute allows you to 
"push" variable assignments up). Immutability is also something that would be 
good *but* it is impractical as done in Ant1 as can be seen by our own 
"distributions" target ;) It *could* work with something like (4) implemented 
(ie declaration of name is immutable and can only be assigned once) thought I 
am really not sure.

I would like to make "user" properties somehow different from "project" 
properties aswell. Essentially the difference would be when setting them. If 
a project property is set but a user property with same name exists then the 
project proeprty is silently ignored. (This would hold even if we assume 
immutable properties. In which case all other cases where a varaible is reset 
would raise an exception).

 
Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*

Re: [ant2] Propertys and strategies to deal with them

Posted by Ken Wood <kw...@i2.com>.
Maybe I missed this in all the debate, but...

Peter Donald wrote:

> 2. Are properties mutable or immutable?

Can't we resolve this by having properties, which are by nature
immutable, and variables, which by nature ARE mutable.?

I.e.

  <property name="version" value="2.1" />
  <property name="base" value="/project/release" />

  <variable name="install_dir" value="${base}/jrun/${version} />

     do some work...using ${install_dir} as needed.

  <variable name="install_dir" value="${base}/websphere/${version} />

     do some more work..using ${install_dir} as needed.

  <variable name="install_dir" value="${base}/tomcat/${version} />

     do some more work..using ${install_dir} as needed.

Properties would NOT be override in build files called from a build
file, but variables could be.

Re: [ant2] Propertys and strategies to deal with them

Posted by Stefan Bodewig <bo...@apache.org>.
Peter Donald <do...@apache.org> wrote:

> 1. How do we scope properties?  

Yet to be decided, right.  I see global, build file and maybe
task-local scope, where the last applies to container-tasks.  Not sure
what target scope would be used for.

> 2. Are properties mutable or immutable?

We have promised to deliver a built-in task that can modify
properties, so some properties themselves can be mutable.  That
doesn't mean, that all of them have to be mutable by default.

> 3. Is there a difference between passed in parameters (via
> ant.properties or CLI) and build file specified properties?

Just for precedence rules IMHO (in the sense that explicitly passed in
properties always take precedence).

> 4. Should we allow declaration of variables without assignment?

What would they do?  Just define scope?  I'd prefer an explicit
attribute for this.  Say you have several property declaration inside
a container-task - I wouldn't want to search through the build file to
know which scope they live in.

Stefan