How do I create a versioned jar file using Ant?
Author: Deron Eriksson
Description: This tutorial describes how to create a versioned jar file using Ant's buildnumber task
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 1.5.1

Page: < 1 2 3 >

(Continued from page 1)

If we execute 'build-jar-version', we see the following result in the console:

Buildfile: C:\projects\workspace\team-cakes-utilities\build.xml
   [delete] Deleting directory C:\projects\workspace\team-cakes-utilities\bin
    [mkdir] Created dir: C:\projects\workspace\team-cakes-utilities\bin
    [javac] Compiling 2 source files to C:\projects\workspace\team-cakes-utilities\bin
    [mkdir] Created dir: C:\projects\workspace\team-cakes-utilities\build-version
      [jar] Building jar: C:\projects\workspace\team-cakes-utilities\build-version\team-cakes-utilities-1.0.jar
Total time: 1 second

In the Navigator view, we can see that the build-version directory was created, and the team-cakes-utilities-1.0.jar file was placed in the directory. The build.number file was created in the project's root directory.

team-cakes-utilities-1.0.jar file created

If we execute 'build-jar-version' again, we see that team-cakes-utilities-1.1.jar is created and put in the build-version dirctory.

team-cakes-utilities-1.1.jar file created

Of course, it's probably a good idea to commit the build.number file to your code repository (such as CVSW) so that the correct version number is saved.

(Continued on page 3)

Page: < 1 2 3 >