ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francis Galiegue <...@one2team.com>
Subject Re: Reset BuildNumber
Date Wed, 06 May 2009 21:23:37 GMT
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="next.@{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
fge@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-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message