ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Master, Tariq \(Abbeywood\)" <Tariq.Mas...@uk.bp.com>
Subject RE: How to fail if macro attribute is not set
Date Mon, 21 Aug 2006 15:58:52 GMT
Scott,

Cheers,  Smart dude! 


To reflect my sillyness.... Ant by default shows the error:

required attribute idea not set



-----Original Message-----
From: Scot P. Floess [mailto:floess@mindspring.com] 
Sent: 21 August 2006 16:47
To: Ant Users List
Subject: Re: How to fail if macro attribute is not set

Here:

<macrodef  name = "SomethingSmart">
    <attribute name = "idea" description = "The blah blah"/>

    <sequential>
       <fail  message = "Cannot do something great unless an idea is
set">
            <condition>
                <isEqual arg1 = "@{idea}"  arg2 = ""/>
            </condition>
       </fail>
    </sequential>
</macrodef>

I think in your example the attribute idea will be required.  Is your
question more like, "how do I ensure the attribute idea is not empty?"  
If so, the above should solve your problem...

I didn't run the above...so there may be some syntax issues...but you
want something like the above...


Master, Tariq (Abbeywood) wrote:
> I would like my macro definition to fail if an attribute is not.
> Example:
>
> <macrodef name="SomethingSmart">
>         <attribute name="idea" description="The blah blah"/>
>         <sequential>
>             <fail message="Cannot do something great unless an idea is
> set" unless="idea"/>
> 		<!--  things to do -->
>         </sequential>
> </macrodef>
>
>
>
> The fail in the above case always fails as the attribute isn't
> recognised as a property.  Unless I'm incorrect.
>
> Ideas or potential idea for Ant 1.7+ ?
>
> Tariq
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
>   

-- 
Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-754-4592 (Work)

Chief Architect JPlate  http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim


---------------------------------------------------------------------
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