Hello Steve,

Here's a solution for <stcheckout> currently in CVS.  

Try calling <stcheckout> with a blank label, i.e. label="".  You should
find it ignores a blank label. Assuming that works, all you have to do is
specify the lbl property as blank:
    <property name="lbl" value="" />

Then, if you want to use a label, either specify it to Ant as
-Dlbl=labelName or use <properties file> to load a file of properties
where lbl is defined to some value.  This would have to be specified
before the default blank value is set.

You can use this technique for any attribute that ignores a blank value.

The Quiet Notation syntax would work in this case as well.  But the above
solution is nearly as easy to use and works today.

-Bill

Steve Cohen wrote:
> 
> I previously sent this idea in a message whose title may have hidden its 
> importance, but this is an idea I'd really like to see and I'd like the 
> developers to comment on it.
> 
> What if there were a convenient syntax within ant for specifying task 
> attributes based on properties
> 
> such that
> 
> if the property were not set
>         the task code would never see the attribute?
> 
> In other words, for example, look at this call:
>   <stcheckout URL="STARTEAM:49201/Aproject/AView"
>      username="auser"
>      password="secret"
>      rootlocalfolder="C:\dev\buildtest\co"
>      forced="true"
>      label = "${lbl}"
>   />
> 
> If the lbl property is defined, the task will get its value as the label 
> attribute.  But if the lbl property is not defined, the task will get the 
> text "${lbl}" and most likely fail.
> 
> I am proposing a new syntax that would allow a property to be specified with 
> a different meaning.  Let's say this syntax is two dollar signs instead of 
> one ($${property}).  (This may not be the optimal symbol for the ant parser, 
> but that is a detail - I am not wedded to any symbol).
> 
> Using this syntax, the above example becomes:
> 
>   <stcheckout URL="STARTEAM:49201/Aproject/AView"
>      username="auser"
>      password="secret"
>      rootlocalfolder="C:\dev\buildtest\co"
>      forced="true"
>      label = "$${lbl}"
>   />
> 
> My proposal is that this syntax be interpreted this way:
> 
> If the property lbl is defined, treat $${lbl} exactly as ${lbl} but
> if the property lbl is not defined, do not even pass the label attribute to 
> the task.
> 
> It seems to me that this would allow for much more flexible scripts, 
> especially when more than one parameter of a task is optional and there are 
> different use cases for the task.  In the above example, to get the variable 
> functionality desired, I must include two blocks in my script, one with the 
> label attribute defined and the other without it, and put it some 
> conditionals to direct the processing to the right place.  This can get 
> clumsy, especially if there are several attributes to parameterize; the 
> combinatorial possiblilities could be large, making for scripts that are 
> harder to understand or maintain.
>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to