Another try to include extended control-flow :-) How about extending the pattern of a Task to allow any task to become and element of a task if it allow it?
For Example: <if ...> <echo...> <fail ...> </if> iff the task "if" has a method "public Task createTask(String name)". This will allow people to include stuff like this (and even <foreach in="a,b,c"/> which is missing below :-) ) Nico ----- Original Message ----- From: "Marcel Ruff" <[EMAIL PROTECTED]> To: "ant-user" <[email protected]> Sent: Wednesday, November 08, 2000 9:18 AM Subject: Control flow (if,while,for) proposal in ant (xml based). > Hi, > > what about some control flow in build.xml: > > > <if string="${MYAPP}" equals="cool" target="build_cool" /> > > Here if the environment MYAPP is set to "cool", > the target "build_cool" is invoked. > Other attributes could be 'notequals' 'contains_substring' etc. > > <if string="${MYAPP}" length="0" target="build_error" /> > > Here if the string size is 0 (MYAPP not set) we jump > to target "build_error". > > > The "else if" control flow could look as follows: > > <if string="${MYAPP}" length="0" target="build_error"> > <elseif string="${MYAPP}" equals="cool" target="build_cool"/> > <elseif string="${MYAPP}" equals="tomcat" target="deploy_tomcat"/> > <else target="deploy_jboss"/> > </if> > > > The "while" could look like: > > <while> > ... > <if string="${MYAPP}" length="0" action="continue" /> > ... > <if string="${MYAPP}" equals="cool" target="build_cool" /> > ... > <if string="${STOP_IT}" equals="true" action="break" /> > ... > </while> > > Anywhere else we can set > > <property name="STOP_IT" value="true"/> > > to stop the loop. > > > The "for" could look like: > > <for iterator="ii" start="0" end="10" step="1"> > ... > <if int="${ii}" equals="5" target="build_cool" /> > ... > <if int="${ii}" ge="7" target="build_other" /> > ... > <if string="${STOP_IT}" equals="true" action="break" /> > ... > </for> > > The 'iterator' attribute declares the name of the iterator > variable. > The attributes for 'if' when of type 'int' could be > 'ge' (greater or equals), le (lower or equals) etc. > > To know more about the users environment, we could extend > the "ant" script with a shell loop feeding all OS env settings > to ant: > > #--------------------- > # ant > ... > ALL_ENV=`env` > MY_DEF="" > for i in ${ALL_ENV} ; do > MY_DEF="${MY_DEF} -Denv.$i" > done > $JAVACMD -classpath $LOCALCLASSPATH -Dant.home=${ANT_HOME} ${MY_DEF} > $ANT_OPTS org.apache.tools.ant.Main $@ > ----------------------- > > The environment variable > $TOMCAT_HOME > would be available in build.xml like > ${env.TOMCAT_HOME} > > The token 'env.' is a namespace to classify operating system > environment variables. > > (I don't know how such stuff is done with Windows, is anybody > out there still using win?) > > > I could implement it (but the next weeks i have no time > at all). > > What do you think > does it makes sense? > > Marcel > > > -- > Marcel Ruff > mailto:[EMAIL PROTECTED] > http://www.lake.de/home/lake/swand/ > http://www.xmlBlaster.org
