Location: JWare Software » AntXtras » Documents » How Tos » AntXtras Version
AntXtras Version
Q: How do I get the active AntXtras version?
Use the AntXtras <vendorinfo> task to copy the AntXtras release information to a set of project properties. The full set of release information includes a label, version, long version, (build) date, long (build) date, and (build) platform; however, you can extract a subset of these fields. The <vendorinfo> task works automatically for all AntXtras-based Ant extensions; use the ‘name’ parameter to define one of the known AntXtras sub-projects or another third-party vendor. If you do not name a specific vendor or AntXtras sub-project, <vendorinfo> assumes AntXtras/Foundation.
The following snippet copies all the AntXtras release information to a set of properties prefixed with “antxtras.”.
<vendorinfo prefix="antxtras."/> <echo message="AntXtras Release: ${antxtras.build.label}"/>
[2.0+] If you’ve loaded AntXtras from a custom classpath, you need to provide that same path to <vendorinfo>1) so it can find the release information The following snippet demonstrates how you might do this. Note on line 9, in the original <taskdef> that loads in the AntXtras antlib, we create a classloader reference for reuse. We can reuse this loader with other <taskdef> calls or any AntXtras component that takes a classpath like <vendorinfo> does.
1: <path id="tools.path"> 2: <fileset dir="${ant.extensions.d}/antxtras"> 3: <include name="lib/*.jar"/> 4: </fileset> 5: … 6: </path> 7: … 8: <taskdef resource="org/jwaresoftware/antxtras/install/antlib.xml" 9: classpathref="tools.path" loaderref="tools.classloader"/> 10: … 11: <vendorinfo prefix="antxtras." loaderref="tools.classloader"/> 12: <echo message="AntXtras Release: ${antxtras.build.label}"/>
The following snippet captures only the “version” and “date” information in two properties prefixed with “sams.”. Note that the “build.” [sub-]prefix is prepended automatically by AntXtras; you cannot remove this sub-prefix.
<vendorinfo name="sams" fields="version,date"/> <echo message="SAMS Version: ${sams.build.version}"/> <echo message="SAMS Build Date: ${sams.build.date}"/>
If AntXtras cannot find the named vendor (or sub-project), it substitutes a no-op set of release information; it does not signal an error!
Release Information
Below is the complete set of release information that <vendorinfo> provides by field name. These are the names you must use to extract partial information. Note that AntXtras does not restrict what each of these fields should contain or in what format; the values are just free-formed strings to us.
- LABEL=“label”
- VERSION=“version”
- LONGVERSION=“longversion”
- DATE=“date”
- LONGDATE=“longdate”
- PLATFORM=“platform”
- HOST=“host”
[2.0+] To use <vendorinfo> with your own release information2), create a standard Java properties file named like “<vendorname>-version.properties” and put it somewhere in your classpath. For each of the field property names, define a string value; see sample below for property names. AntXtras will load these properties as the values for the various fields. An example properties file for “acmesauce-version.properties” might look like:
ID=acmesauce displayName=ACME Corp's Special Sauce v2.1.5, 14-Jun-2008 version=2.1.5 buildVersion=2.1.5_build5129.165 abbrDate=14-Jun-2008 GMT longDate=17:27:58 14-Jun-2008 GMT hostID=bldmach07.pa.example.com OS=Windows XP/SP3 PL245
Then to extract information from an Ant script you would use <vendorinfo> like:
<vendorinfo name="acmesauce" prefix="acme"/> <echo message="Release information: ${acme.build.label}"/> <echo message="More: ${acme.build.host} ${acme.build.platform}"/>
AntXtras Sub-projects
Below is the list of AntXtras-subproject names as of June-2008 (aliases are listed in square brackets[]). If your AntXtras/Foundation installation is newer than June-2008, it might support additional projects and/or aliases.
- antxtras [antx]
- log4ant [slf4ant]
- ped4ant
- svn4ant
- canary [antunit]
- sams [sam]
- verz4ant [verz]