Dez 062011

Versioned jars (like MyCode-1.2.jar) can be easily generated with ant.

First you have to set the necessary Properties:

<property name="major-version-number" value="0" />
<property name="project-name" value="${}" />
<property name="src" value="src"/>
<property name="build" value="bin" />

Then you need a compile-task:

<target name="compile" description="compile the source" >
    <javac srcdir="${src}" destdir="${build}"/>

Then you need a method for generating jars:

<target name="jar-version">
  <buildnumber />
  <property name="version-number" value="${major-version-number}.${build.number}" />
  <jar basedir="bin" destfile="build-version/${project-name}-${version-number}.jar">
     <attribute name="Built-By" value="${builder}" />
     <attribute name="Built-On" value="${build-info.current-date}" />
     <attribute name="Built-At" value="${build-info.current-time}" />
     <attribute name="Implementation-Version" value="${version-number}" />

At last you need a method that compiles the files, generates the build-number and the jar-File:

<target name="build-jar-version">
    <antcall target="compile" />
    <mkdir dir="build-version" />
    <antcall target="jar-version" />

Sorry, the comment form is closed at this time.