Bitten is a trac plugin for continuous integration which I use for the antdiff project and it does a good job in getting the daily builds organized. One nice feature is the summary for unit tests and code coverage tools (I use corbertura). But what I was missing was a similar summary for my checkstyle reports.
But thanks to XSLT, there is a simple solution: Bitten is able to include test and coverage reports from xml files. And since checkstyle generates a xml file for the results, it was straight-forward to translate the checkstyle xml file to a xml file for bitten. The only problem is that bitten only knows the two mentioned types of reports, so I decided to use the test report.
And this is the (extremely simple) stylesheet:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="file">
<xsl:choose>
<xsl:when test="count(error) = 0">
<test status="success" fixture="{@name}" name="No checkstyle errors" file="{@name}" />
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="error">
<test status="error" fixture="{../@name}" name="{@message}" file="{../@name}" />
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="checkstyle">
<report category="test">
<xsl:apply-templates/>
</report>
</xsl:template>
</xsl:stylesheet>
Translating the checkstyle xml report using this stylesheet allows you to treat checkstyle results in the same way as unit test failures.
But there is one slight problem: the file names in the checkstyle xml are absolute file names. Hence also the file names in the bitten build summary are absolute. In my setup this means having something like “/tmp/bittenFpQXrh/build_Trunk_22″ in front of the name, which doesn’t look good and it also breaks the link to the source code. The simple solution was to remove the path name from the checkstyle report using the following ant task:
<replace file=“${dir.reports}/checkstyle_report.xml” token=“${basedir}” value=“”/>
Maybe it would be nice not to link the checkstyle results to the source code, but rather to the html reports which give more information about the details of the problem.
Please see on of the antdiff build status pages as an example (click on “Test results” in the checkstyle section).