So, here's the deal:
We want to instrument the development process for Hackystat, i.e. we want to
have hackystat sensors monitoring hackystat development itself.
However, we don't want our external installers of the Hackystat server to have
to install Hackystat sensors just so they can install a Hackystat server from a
binary distribution.
Finally, we don't want to use <antcall>, because it's slow and bogus.
This is a problem. :-)
Here's the best solution I have come up with so far.
We already know that we have to have different versions of antsensor.build.xml
file for the development environment (i.e. what you get when you download the
sources from SVN) and the distribution environment (i.e. what you get when you
unpack hackystat-<config>-<version>.zip). By having different versions of
this file, it allows us to have a 'real' implementation of the Ant sensor when
doing development (which requires developers to actually install the Ant
sensor) and a 'fake' (no-op) version of the sensor in the distribution
environment (which does nothing when called, and does not require people to
install the Ant sensor in order to install a server).
I propose that we generalize this approach to _all_ Hackystat sensors that we
want to use in our Ant build system for Hackystat. Instead of an
antsensor.build.xml file, we'll have a hackystat.sensor.build.xml file. This
file will be imported in build.xml. The version of hackystat.sensor.build.xml
in SVN will basically contain a set of taskdefs, such as
<taskdef name="hacky-junit" classname="org.hackystat.sensor.junit.JUnitSensor"
/>
People doing development in Hackystat will thus be required to install all of
these sensors. (Hey, you're a Hackystat developer, you're supposed to _like_
installing sensors. :-) The rest of the build system files invoke the sensors
in the normal way, such as:
<hacky-junit verbose="${hackystat.sensor.verbose}">
<fileset dir="${junit.report.dir}">
<include name="**/TEST-*.xml"/>
</fileset>
</hacky-junit>
Here's the tricky part. When creating the destribution zip file, we include a
'fake' version of hackystat.sensor.build.xml. This file doesn't contain the
taskdefs for the sensors. Instead, it contains a set of macrodefs that
'simulate' the syntax of the actual sensor tasks, but don't do any actual work.
For example:
<macrodef name="hacky-junit">
<attribute name="verbose" default=""/>
<element name="fileset" optional="yes"/>
<sequential>
</sequential>
</macrodef>
Thus, the build system in a distribution can still invoke <hacky-junit> and Ant
won't complain, but of course no sensor data will be collected.
We can keep a file called 'dist.hackystat.sensor.build.xml' in the lib
directory, and copy it over to hackystat.sensor.build.xml when making
distributions. It should change very slowly, and so we can maintain it by
hand.
Comments?
Cheers,
Philip