You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Marcus Lindblom <ma...@yar.nu> on 2006/09/09 19:05:44 UTC

Customizable handling of unset properties

Hi,

I just want to ask a bit something that probably has been discussed to 
death before: unset properties handling. The latest 1.7 does not address 
this (according to the release notes), and I could find no enhancement 
request discussing it either.

So, my simple proposal is:

Allow the user to set a custom handler for resolving properties (with 
the option to handle unset properties as errors), similar to setting 
build listeners.

We've been running with a modified Ant 1.6.2 for some time that simply 
throws an exception if a non-set property is accessed (when another 
propery is set, namely ant.disallow_unset_properties). It works really 
nice for us and has helped finding quite a few bugs (that's why we added 
it in the first place), but a more general solution would be to provide 
various property-policies. That way, I could resolve my other issue (see 
my recent post) that way as well, making it a bit more transparent.

Comments?

Cheers,
/Marcus

P.S. I could probably check out 1.7 and make a patch myself, if you guys 
think it's worthwhile to include in the future.




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


Re: Customizable handling of unset properties

Posted by Marcus Lindblom <ma...@yar.nu>.
Ok. Someone had provided a patch in issue 40093, which adresses this, so 
I'll just wait for that one to be merged into ant proper then.

The PropertyHelper class is indeed rather confusing.

Thanks,
/Marcus

Peter Reilly wrote:
> Replacement of propertyhelper is broken in current ant:
> see:
> http://issues.apache.org/bugzilla/show_bug.cgi?id=40093
> and
> http://issues.apache.org/bugzilla/show_bug.cgi?id=25998
> However some people have done it see:
> http://www.efanomars.net/pf/
>
> My feeling that the replacement of propertyhelper was
> always broken and it is a very heavy handed way of
> adding custom property handling.
> Note that PropertyHelper also provides an alternative
> way of adding optional behavour - using hooks. I think
> that this is also broken (I do not understand what it
> is meant to do). PropertyHelper also has "namespace"
> attributes ... which do not get used.
>
>
> Peter
>
>
>
> On 9/20/06, Marcus Lindblom <ma...@yar.nu> wrote:
>>
>> Marcus Lindblom wrote:
>> > Dominique Devienne wrote:
>> >>> I am sure other Ant committers will feel differently. I do not see a
>> >>> big urge to implement this.
>> >>>
>> >>> On the other side, why not ?
>> >> [snip}
>> >>
>> > Righto. I'll see what I can come up with then. :)
>> I got response on the bugzilla issue, that there is a PropertyHelper
>> class that I should be able to override to do this. It is, apparently,
>> just a bit awkward to replace the current instance. However, I was
>> informed that it should be doable with a <script> task. Fair enough. :)
>> .. I'm posting here be
>>
>> Has anyone any experience with doing that, because I don't know where to
>> set that class? (I'd assume not, otherwise I would have expected to be
>> pointed there on my first post. :)
>> PropertyHelper.getPropertyHelper(Project p) .. doesn't seem get what I
>> want, and the doc for that function indicates that it's a factyr method,
>> thus creating a new object.
>>
>> Any input?
>>
>> Cheers,
>> /Marcus
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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: Customizable handling of unset properties

Posted by Peter Reilly <pe...@gmail.com>.
Replacement of propertyhelper is broken in current ant:
see:
http://issues.apache.org/bugzilla/show_bug.cgi?id=40093
and
http://issues.apache.org/bugzilla/show_bug.cgi?id=25998
However some people have done it see:
http://www.efanomars.net/pf/

My feeling that the replacement of propertyhelper was
always broken and it is a very heavy handed way of
adding custom property handling.
Note that PropertyHelper also provides an alternative
way of adding optional behavour - using hooks. I think
that this is also broken (I do not understand what it
is meant to do). PropertyHelper also has "namespace"
attributes ... which do not get used.


Peter



On 9/20/06, Marcus Lindblom <ma...@yar.nu> wrote:
>
> Marcus Lindblom wrote:
> > Dominique Devienne wrote:
> >>> I am sure other Ant committers will feel differently. I do not see a
> >>> big urge to implement this.
> >>>
> >>> On the other side, why not ?
> >> [snip}
> >>
> > Righto. I'll see what I can come up with then. :)
> I got response on the bugzilla issue, that there is a PropertyHelper
> class that I should be able to override to do this. It is, apparently,
> just a bit awkward to replace the current instance. However, I was
> informed that it should be doable with a <script> task. Fair enough. :)
> .. I'm posting here be
>
> Has anyone any experience with doing that, because I don't know where to
> set that class? (I'd assume not, otherwise I would have expected to be
> pointed there on my first post. :)
> PropertyHelper.getPropertyHelper(Project p) .. doesn't seem get what I
> want, and the doc for that function indicates that it's a factyr method,
> thus creating a new object.
>
> Any input?
>
> Cheers,
> /Marcus
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

Re: Customizable handling of unset properties

Posted by Marcus Lindblom <ma...@yar.nu>.
Marcus Lindblom wrote:
> Dominique Devienne wrote:
>>> I am sure other Ant committers will feel differently. I do not see a
>>> big urge to implement this.
>>>
>>> On the other side, why not ?
>> [snip}
>>
> Righto. I'll see what I can come up with then. :)
I got response on the bugzilla issue, that there is a PropertyHelper 
class that I should be able to override to do this. It is, apparently, 
just a bit awkward to replace the current instance. However, I was 
informed that it should be doable with a <script> task. Fair enough. :)  
.. I'm posting here be

Has anyone any experience with doing that, because I don't know where to 
set that class? (I'd assume not, otherwise I would have expected to be 
pointed there on my first post. :) 
PropertyHelper.getPropertyHelper(Project p) .. doesn't seem get what I 
want, and the doc for that function indicates that it's a factyr method, 
thus creating a new object.

Any input?

Cheers,
/Marcus



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


Re: Customizable handling of unset properties

Posted by Marcus Lindblom <ma...@yar.nu>.
Dominique Devienne wrote:
>> I am sure other Ant committers will feel differently. I do not see a
>> big urge to implement this.
>>
>> On the other side, why not ?
>
> Yes, why not. Referencing an unset property is indeed often a bug in
> the build, although not always. I have thought myself than an "sh"
> property handler, which implements the usual Bourne-Shell type checks
> and alternate values on property replacement would take case of such
> an issue, but it would force using the property handler's prefix.
>
> Something like ${sh:foo:?} would fail the build if foo is undefined.
> The notation doesn't exactly look clean, but the functionality would
> be worthwhile I think. --DD
Righto. I'll see what I can come up with then. :)

/Marcus

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


Re: Customizable handling of unset properties

Posted by Dominique Devienne <dd...@gmail.com>.
> I am sure other Ant committers will feel differently. I do not see a
> big urge to implement this.
>
> On the other side, why not ?

Yes, why not. Referencing an unset property is indeed often a bug in
the build, although not always. I have thought myself than an "sh"
property handler, which implements the usual Bourne-Shell type checks
and alternate values on property replacement would take case of such
an issue, but it would force using the property handler's prefix.

Something like ${sh:foo:?} would fail the build if foo is undefined.
The notation doesn't exactly look clean, but the functionality would
be worthwhile I think. --DD

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


Re: Customizable handling of unset properties

Posted by Antoine Levy-Lambert <an...@gmx.de>.
Hello Marcus,

I am sure other Ant committers will feel differently. I do not see a  
big urge to implement this.

On the other side, why not ?

If you want, open a bug report concerning this idea. Be sure to add  
to the bug report source code, documentation and testcases.
New files can be added to the bug report in tar or zip format, for  
existing files use svn diff to generate a "patch.txt".

Regards,

Antoine


On Sep 19, 2006, at 2:33 PM, Marcus Lindblom wrote:

> Sorry for bouncing. I'm just wondering if there is somewhere (other  
> than this list) where this is better dicusssed?
>
> /Marcus
>
> Marcus Lindblom wrote:
>> Hi,
>>
>> I just want to ask a bit something that probably has been  
>> discussed to death before: unset properties handling. The latest  
>> 1.7 does not address this (according to the release notes), and I  
>> could find no enhancement request discussing it either.
>>
>> So, my simple proposal is:
>>
>> Allow the user to set a custom handler for resolving properties  
>> (with the option to handle unset properties as errors), similar to  
>> setting build listeners.
>>
>> We've been running with a modified Ant 1.6.2 for some time that  
>> simply throws an exception if a non-set property is accessed (when  
>> another propery is set, namely ant.disallow_unset_properties). It  
>> works really nice for us and has helped finding quite a few bugs  
>> (that's why we added it in the first place), but a more general  
>> solution would be to provide various property-policies. That way,  
>> I could resolve my other issue (see my recent post) that way as  
>> well, making it a bit more transparent.
>>
>> Comments?
>>
>> Cheers,
>> /Marcus
>>
>> P.S. I could probably check out 1.7 and make a patch myself, if  
>> you guys think it's worthwhile to include in the future.
>>
>>
>>
>>


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


Re: Customizable handling of unset properties

Posted by Marcus Lindblom <ma...@yar.nu>.
Sorry for bouncing. I'm just wondering if there is somewhere (other than 
this list) where this is better dicusssed?

/Marcus

Marcus Lindblom wrote:
> Hi,
>
> I just want to ask a bit something that probably has been discussed to 
> death before: unset properties handling. The latest 1.7 does not 
> address this (according to the release notes), and I could find no 
> enhancement request discussing it either.
>
> So, my simple proposal is:
>
> Allow the user to set a custom handler for resolving properties (with 
> the option to handle unset properties as errors), similar to setting 
> build listeners.
>
> We've been running with a modified Ant 1.6.2 for some time that simply 
> throws an exception if a non-set property is accessed (when another 
> propery is set, namely ant.disallow_unset_properties). It works really 
> nice for us and has helped finding quite a few bugs (that's why we 
> added it in the first place), but a more general solution would be to 
> provide various property-policies. That way, I could resolve my other 
> issue (see my recent post) that way as well, making it a bit more 
> transparent.
>
> Comments?
>
> Cheers,
> /Marcus
>
> P.S. I could probably check out 1.7 and make a patch myself, if you 
> guys think it's worthwhile to include in the future.
>
>
>
>
> ---------------------------------------------------------------------
> 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