Friday, April 8, 2011

Giving Version / Build information in Java project

For several of my projects I capture the subversion revision number, time, user who ran the build, and some system information, stuff them into a .properties file that gets included in the application jar, and read that jar at runtime. The ant code looks like this:



<property name="version" value="1.23"/>

<target name="buildinfo">
<tstamp>
<format property="builtat" pattern="MM/dd/yyyy hh:mm aa" timezone="America/New_York"/>
tstamp>
<exec executable="svnversion" outputproperty="svnversion"/>
<exec executable="whoami" outputproperty="whoami"/>
<exec executable="uname" outputproperty="buildsystem"><arg value="-a"/>exec>

<propertyfile file="path/to/project.properties"
comment
="This file is automatically generated - DO NOT EDIT">
<entry key="buildtime" value="${builtat}"/>
<entry key="build" value="${svnversion}"/>
<entry key="builder" value="${whoami}"/>
<entry key="version" value="${version}"/>
<entry key="system" value="${buildsystem}"/>
propertyfile>
target>


Starting and Stopping of tomcat using ANT command

Starting of tomcat:

Starting of Tomcat


Stopping of tomcat
value="-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"/>