ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Enrique Urieles Nieto <aeuriel...@gmail.com>
Subject Re: Set a default value to property.
Date Tue, 30 Nov 2010 19:24:53 GMT
What may it be wrong about simply using:

<project name="Foo" default="foo" basedir=".">
    <property name="bar" value="default"/>
    <target name="foo" description="foo">
        <echo message="${bar}" />
    </target>
</project>

Since properties are immutable and if it was set in the command line
call it won't change?

Best regards,

Alexander.

On Tue, Nov 30, 2010 at 8:20 PM, Scot P. Floess <sfloess@nc.rr.com> wrote:
> Clearly my snippet is wrong:
>
>    <macrodef name="default">
>        <attribute name="property"/>
>        <attribute name="default"/>
>        <attribute name="description" default=""/>
>
>        <sequential>
>            <condition property="@{property}" value="@{default}">
>                <not>
>                    <isset property="@{property}"/>
>                </not>
>            </condition>
>        </sequential>
>    </macrodef>
>
> ----- Call to <isset> was using the wrong attribute
>
> On Tue, 30 Nov 2010, Scot P. Floess wrote:
>
>>
>> Here is something I like to use...  I macrodef'd it out so I can call it
>> for many properties that require default values...
>>
>>    <macrodef name="default">
>>        <attribute name="property"/>
>>        <attribute name="default"/>
>>        <attribute name="description" default=""/>
>>
>>        <sequential>
>>            <condition property="@{property}" value="@{default}">
>>                <not>
>>                    <isset property="@{name}"/>
>>                </not>
>>            </condition>
>>        </sequential>
>>    </macrodef>
>>
>> This works with stock Ant (meaning you don't need Ant-contrib or any third
>> party libraries)...
>>
>> To use:
>>
>> <default property="SomeProperty" default="Some Default Value"/>
>>
>>
>>
>> On Tue, 30 Nov 2010, ritchie wrote:
>>
>>>
>>>  My ant script takes a value for a property at runtime(-Denv=xxx), if the
>>>  argument is not passed i want the value to be set as a default arbitary
>>>  value. How to accomplish this?
>>>
>>
>>
>
> --
> Scot P. Floess
>
>
> RHCT  (Certificate Number 605010084735240)
>
> Chief Architect FlossWare  http://sourceforge.net/projects/flossware
>                           http://flossware.sourceforge.net
>                           https://github.com/organizations/FlossWare
>
> Chief Architect JPlate     http://sourceforge.net/projects/jplate
> Chief Architect JavaPIM    http://sourceforge.net/projects/javapim
> Chief Architect Keros      http://sourceforge.net/projects/keros
>
> ---------------------------------------------------------------------
> 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


Mime
View raw message