My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
BuildNumber  
Extract SVN revision number into the build number string
Updated Feb 6, 2011 by sasha...@gmail.com

Introduction

This component makes it easy to incorporate the current SVN revision number into the built Java artifact.

It can be used as:

  • Maven Mojo (plugin)
  • Ant Task

The component looks at the source directory specified by the user and creates the file in the Java Properties format that contains the information requested. See below for the format.

The component uses the "svnversion" command and assumes that the command-line Subversion client is installed.

Input

  • basedir -- the location of directory where the SVN checkout has been made
  • outputPath -- the path of the output file. The default is $buildDirectory/buildnumber.properties
  • buildDirectory -- the path of the build directory. The default is extracted from the build system.

Output

buildnumber creates file named "buildnumber.properties" in the directory specified by the user. The file has the following format:

build.number=<SVN-revision-number>
build.modified=<modified>
build.timestamp=<yymmdd-hhmm>

Where

  • SVN-revision-number -- the last checked out/updated SVN revision number of the $basedir
  • modified -- true | false, whether the files were modified since the checkout/update
  • yymmdd-hhmm -- timestamp of the build operation. In the absence of the SVN checkout information could be used as "poor man's" build number.

Maven Plugin Example

<project>
    <pluginRepositories>
        <pluginRepository>
            <id>codebistro-repo</id>
            <name>codebistro repo</name>
            <layout>default</layout>
            <url>http://codebistro.googlecode.com/svn/repo/</url>
        </pluginRepository>
    </pluginRepositories>
    <build>
        <plugins>
            <plugin>
                <groupId>org.codebistro.tools</groupId>
                <artifactId>buildnumber</artifactId>
                <version>1.0-SNAPSHOT</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate-resources</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <outputPath></outputPath>
                    <basedir>...</basedir>
                    <buildDirectory>${project.build.directory}</buildDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Ant Task Example

Assume you downloaded the latest version of the jar from the repository to say ${basedir}/build.support/buildnumber.jar .

	<target name="init">
            <taskdef name="svnbuildnumber" classname="org.codebistro.tools.BuildNumberTask"           classpath="${basedir}/build.support/buildnumber.jar"/>        
	</target>
         ...
	<target name="build"" />
            <svnbuildnumber baseDir="${basedir}/sec" outputPath="${basedir}/build/classes/buildnumber.properties"/> 
        </target>

Sign in to add a comment
Powered by Google Project Hosting