ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Andrew.Beac...@nokia.com>
Subject RE: Build numbers - always available (all targets), sometimes incremented (compile target only)
Date Mon, 11 Feb 2002 14:39:23 GMT
Chris,

> I'm trying to create a build file that includes a build number.
> 
> The build number should be stored externally.  It should always 
> be loaded with either the most recent build number, or a default 
> value. When the "compile" target is run, the number should be 
> incremented, saved [to disk], and the new value should be available 
> for the rest of the script.  I would like the appropriate build 
> number to be included in the documentation.

I can't answer all your questions but I have done something similar 
with the build number, only increment during compile, but available 
for all tasks.

So this is what I had done...

The build number is stored in an external properties file, and if it 
doesn't exist then the build script will create and store the build 
number in the property file.

Here are the specific targets to show you the details:

    <!-- init.compile -->
    <!-- used by other ant targets, not to be called by the build user -->
    <target name="init.compile"
            depends="">
        <!-- format the current date & time -->
        <tstamp>
            <format property="time.start" pattern="HH:mm MMMM d, yyyy"/>
        </tstamp>

        <!-- increment the build number in the build.properties -->
        <propertyfile file="build.properties">
            <entry key="build.date" type="string" value="${time.start}"/>
            <entry key="build.number" type="int" operation="+" pattern="0000"/>
        </propertyfile>
    </target>

This target is only called by the compile target, and purely sets the 
date and time (also stored in the properties file) and increments the 
build number, or creates one if it doesn't exist.

    <!-- init -->
    <target name="init"
            depends=""
            description="build initialization">
        <!-- set up the output logs -->
        <record name="build.log" append="no"/>
        <record name="buildVerbose.log" append="no" loglevel="verbose"/>
        <!-- get the current date & time -->
        <tstamp/>

        <!-- make the build.properties file variables available -->
        <property file="build.properties"/>
    </target>

This target is called by all other targets, it loads the build.properties 
file which contains the build number and date and time that the last compile 
was issued.  It also sets up the logging files.

    <!-- compile -->
    <target name="compile"
            depends="init.compile, init, info"
            description="compile the java">
        <javac>
            ...
        </javac>
    </target>

Calls init.compile and then init (info just prints property info using <echo>

    <!-- javadoc -->
    <target name="javadoc"
            depends="init, info"
            description="generate the JavaDoc">
        <javadoc>
            ...
        </javadoc>
    </target>

Calls just init, and so it uses the current build number.

Hope this helps, just try the above and then ask me if you need any more help.

Good luck!

Andy.

--
Andrew Beacock
Senior Software Engineer/Project Lead
Nokia Mobile Phones
NMP/MSW/SSP/AG

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message