Tuesday, March 04, 2003

Best Practice; Ant; Always Have a Versions Task

This task is designed to display the version of every software application used during the build process. It will mainly be used when sending a debugging report to vendors. However, it could also be useful when creating archival information. Here is my implementation of a VERSIONS task:

<target name="versions">
	<!-- DOS version -->
	<exec executable="cmd.exe"><arg line="/c ver" /></exec>
	<!-- ANT version -->
	<echo>${ant.version}</echo>
	<!-- SolarMetric's KODO version -->
	<java classname="com.solarmetric.kodo.conf.JDOVersion" fork="yes">
		<classpath>
			<pathelement location="${kodo.jdo.classfile}" />
			<pathelement location="${kodo.impl.home.dir}\lib\jdo1_0.jar" />
			<pathelement location="${kodo.impl.home.dir}\lib\serp.jar" />
			<pathelement location="${kodo.impl.home.dir}\lib\jta-spec1_0_1.jar" />
			<pathelement location="${kodo.impl.home.dir}\lib\jca1.0.jar" />
		</classpath>
	</java>
</target>

When I run ant versions, here is the resulting output:

Buildfile: build.xml

versions:

     [exec] Microsoft Windows XP [Version 5.1.2600]
     [echo] Apache Ant version 1.5 compiled on July 9 2002
     [java] Kodo JDO Enterprise Edition version 2.3.1
     [java] version id: kodojdo-2.3.1-20020821-1709

     [java] os.name: Windows XP
     [java] os.version: 5.1
     [java] os.arch: x86

     [java] java.version: 1.4.0_01
     [java] java.vendor: Sun Microsystems Inc.

     [java] java.class.path:
     [java]     D:\java\jdo\impl\kodo-jdo-2.3.1\lib\kodo-jdoee.jar
     [java]     D:\java\jdo\impl\kodo-jdo-2.3.1\lib\jdo1_0.jar
     [java]     D:\java\jdo\impl\kodo-jdo-2.3.1\lib\serp.jar
     [java]     D:\java\jdo\impl\kodo-jdo-2.3.1\lib\jta-spec1_0_1.jar
     [java]     D:\java\jdo\impl\kodo-jdo-2.3.1\lib\jca1.0.jar

     [java] user.dir: D:\java\WORKSP~1\REFERE~1
Post a Comment