ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Jan.Mate...@rzf.fin-nrw.de>
Subject AW: Enums Support
Date Mon, 12 Apr 2010 05:08:00 GMT
Enumerations are only supported when writing tasks.
For Java <5 you extend EnumeratedAttribute. Its main method (abstract in EA) returns the
list of possible values (getValues() is its name I think).
With Java5+ you could use Java enums directly.

There is no enum in properties (inside the buildfile).
    <property name="stage" enum="dev|test|prod"/>
    <property file="..."/> <!--  stage=dev => ok   stage=foo => build exception
-->

When asking for input the task supports asking for specified values
    <input addproperty="stage" validargs="dev,test,prod"/>


Jan


> -----Urspr√ľngliche Nachricht-----
> Von: Antoine Levy Lambert [mailto:antoine@gmx.de] 
> Gesendet: Freitag, 9. April 2010 22:38
> An: Ant Users List
> Betreff: Re: Enums Support
> 
> Raja Nagendra Kumar wrote:
> > Hi,
> >
> > Is it possible to define a property which takes only X,Y, Z 
> values.. and
> > nothing more.. If any other thing is set for that 
> property.. ant should give
> > the error.
> >
> > Sort of Enums in Java.. so that any wrong setting would 
> result in compiler
> > error.
> >
> > Regards,
> > Nagendra
> >
> >
> >
> >
> >   
> Ant has a class called EnumeratedAttribute [out of the top of 
> my head]. 
> There are no enumerated properties, but this is conceivable.
> 
> You can try to write your own extension of the property task. 
> I am not 
> sure whether there would be a consensus among committers to add this 
> function to ant-core ?
> 
> Regards,
> 
> Antoine
> 
> ---------------------------------------------------------------------
> 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