Francis, Very interesting how you nest all the way in and "done" your way out. Is that faster than my if then else if's? Took me a bit to follow it, but that's because I'm not adept yet at using depends. In NAnt, they aren't used as commonly. For this particular application, it would be ideal if Ant had a <switch><case/></switch> task... Oh, sweet, I just realized that antContrib does. I need to give it a go... I'll return with my results and see what you think. Sorry, but all of the depends feel like spaghetti code to me...
Thanks, Eric ________________________________ From: Francis Galiegue <f...@one2team.com> To: Ant Users List <user@ant.apache.org> Sent: Wednesday, May 6, 2009 3:23:37 PM Subject: Re: Reset BuildNumber Le Wednesday 06 May 2009 19:17:25 Eric Fetzer, vous avez écrit : > Get sidetracked? > Yup, but I got the result ;) Here it is. Feel free to ask questions. This file is based on a build.number file which contains the major.number, minor.number, etc properties, and rewrites said file with the new values when it is done. Curiously, you don't reset hotfix if you update revision... I let it as is. I think you'll see where to reset hotfix otherwise. It may be longer than your solution, but I think it is more legible - and more easily extensible. Have fun! ---- <project name="test" basedir="." default="updateBuildNumber"> <!-- vim:set ts=4 noexpandtab syn=ant: --> <taskdef resource="net/sf/antcontrib/antlib.xml"/> <property file="build.number"/> <macrodef name="increment"> <attribute name="victim"/> <sequential> <math result="ne...@{victim}" operand1="$...@{victim}.number}" operation="+" operand2="1" datatype="int"/> </sequential> </macrodef> <target name="init"> <var name="next.major" value="${major.number}"/> <var name="next.minor" value="${minor.number}"/> <var name="next.hotfix" value="${hotfix.number}"/> <var name="next.revision" value="${revision.number}"/> <var name="next.continuous" value="${continuous.number}"/> </target> <target name="andwhat" if="rebuild" depends="init"> <property name="done" value="true"/> </target> <target name="majorIncrement" if="majorIncrement" unless="done" depends="andwhat"> <increment victim="major"/> <var name="next.minor" value="1"/> <var name="next.hotfix" value="1"/> <var name="next.revision" value="1"/> <var name="next.continuous" value="1"/> <property name="done" value="true"/> </target> <target name="minorIncrement" if="minorIncrement" unless="done" depends="majorIncrement"> <increment victim="minor"/> <var name="next.hotfix" value="1"/> <var name="next.revision" value="1"/> <var name="next.continuous" value="1"/> <property name="done" value="true"/> </target> <target name="hotfixIncrement" if="hotfixIncrement" unless="done" depends="minorIncrement"> <increment victim="hotfix"/> <var name="next.revision" value="1"/> <var name="next.continuous" value="1"/> <property name="done" value="true"/> </target> <target name="continuousIncrement" if="continuous" unless="done" depends="hotfixIncrement"> <if> <equals arg1="${cont.reset}" arg2="true"/> <then> <var name="next.continuous" value="1"/> </then> <else> <increment victim="continuous"/> </else> </if> <property name="done" value="true"/> </target> <target name="revisionIncrement" unless="done" depends="continuousIncrement"> <increment victim="revision"/> <property name="done" value="true"/> </target> <target name="updateBuildNumber" depends="revisionIncrement"> <propertyfile file="build.number"> <entry key="major.number" value="${next.major}"/> <entry key="minor.number" value="${next.minor}"/> <entry key="hotfix.number" value="${next.hotfix}"/> <entry key="revision.number" value="${next.revision}"/> <entry key="continuous.number" value="${next.continuous}"/> </propertyfile> </target> </project> ---- -- Francis Galiegue f...@one2team.com Ingénieur système Mob : +33 (0) 683 877 875 Tel : +33 (0) 178 945 552 One2team 40 avenue Raymond Poincaré 75116 Paris --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional commands, e-mail: user-h...@ant.apache.org