Because you always configure file+value with the same value you could tune it:
<macrodef name="check"> <attribute name="property"/> <attribute name="file"/> <sequential> <available property="@{property}" file="@{file}" value="@{file}"/> </sequential> </macrodef> <check property="foo" file="foo.txt"/> <check property="foo" file="${env.FOO}"/> ... Jan >-----Ursprüngliche Nachricht----- >Von: Michael George [mailto:mdgeo...@cs.cornell.edu] >Gesendet: Dienstag, 21. Juli 2009 14:17 >An: Ant Users List >Betreff: Re: AW: a task for selecting among possible options? > >Oh my god that's so much simpler than what I was doing. Thanks! > >--Mike > >jan.mate...@rzf.fin-nrw.de wrote: >> <available property="foo" file="foo.txt" value="foo.txt"/> >> <available property="foo" file="${env.FOO}" value="${env.FOO}/> >> ... more available tasks >> >> Because properties are immutable the first hit wins. >> >> >> Jan >> >> >> >> >>> -----Ursprüngliche Nachricht----- >>> Von: Michael George [mailto:mdgeo...@cs.cornell.edu] >>> Gesendet: Freitag, 17. Juli 2009 04:45 >>> An: user@ant.apache.org >>> Betreff: a task for selecting among possible options? >>> >>> Hello, >>> >>> I'm trying to clean up our build process, and one of the >problems is >>> that everyone on the team uses a different configuration mechanism >>> (environment vars, properties files, manual config,...). >In trying to >>> be backwards compatible with everyone's process I find I >would like a >>> task that sets a property by selecting the first valid item >>> >> >from a list >> >>> of possibilities. For example, I'd like to able to write >>> something like >>> >>> >>> <choice property="foo"> >>> <condition> <available file="@{}/foo.txt" /> </condition> >>> >>> <option value="${env.FOO}" /> >>> <option value="${basedir}/foo" /> >>> <option> >>> <dirset dir="/usr" includes="**/foo*"/> >>> </option> >>> </choice> >>> >>> To mean "set foo to the first of env.FOO, ${basedir}/foo, and >>> /usr/*/foo >>> that contains the file foo.txt." I'd also like to perhaps have the >>> option of prompting the user if multiple valid choices are >found (for >>> example, with select="first" or select="prompt"). >>> >>> Does anyone know of any tasks that would make this kind of >>> configuration >>> easy, before I dive in and try to write one myself? If not, would >>> people find this useful if I code it up and submit it to >ant-contrib? >>> >>> Thanks! >>> >>> --Mike >>> >>> >--------------------------------------------------------------------- >>> To unsubscribe, e-mail: user-unsubscr...@ant.apache.org >>> For additional commands, e-mail: user-h...@ant.apache.org >>> >>> >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscr...@ant.apache.org >> For additional commands, e-mail: user-h...@ant.apache.org >> >> > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: user-unsubscr...@ant.apache.org >For additional commands, e-mail: user-h...@ant.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional commands, e-mail: user-h...@ant.apache.org