This is not the first luntbuild article on this website. I have been working with luntbuild for a while. Still it was only recently I found out the possibility to extend luntbuild. It struc me how easy it is. This article is about the luntbuild exntesion. You can combine it with the cobertura-luntbuild article to fill in the missing link in that article.

First some luntbuild theory, how to extend the ognl possibilities? Create a bean, put it in a jar and add a properties file named luntbuild_extension.properties to this jar with the following contents:

luntbuild.extension.name=CoberturaIntegration
luntbuild.extension.class=com.gridshore.luntbuild.addon.CoberturaIntegration

The bean is just a plain javabean with some public methods. You can create a method that checks if the report directory is available and another method that points to the page to start if you want to have a llok at the reports. This would look like the following:

  private final String coberturaReportDir = "cobertura_report_dir";
  public String getCoberturaReportDir(String publishDir) {
    return publishDir + "\\\\" + coberturaReportDir;
  }
  public String getCoberturaReportDir() {
    return coberturaReportDir;
  }
  public String getCoberturaSite(String publishDir) {
    File pathToFile = (new File(getCoberturaReportDir(publishDir)+ File.separator + "index.html"));
    if(pathToFile.exists()) {
      return coberturaReportDir + "/index.html";
    } else {
      return null;
    }
  }

These methods can be called from luntbuild. There are two important locations where the ognl expressions are used:

  • The build configuration within luntbuild when a project is created.
  • The tapestry view files

Lets start with the ant configuration within Luntbuild:

LuntbuildAntBuildersScreen-1

Pay attention to the coberturaHtmlReportDir here you can see how to pass output from the added bean to ant. From the context you can reach the class ‘com.luntsys.luntbuild.web.BuildViewer’. This class has a method getBuild, this class returns a ‘com.luntsys.luntbuild.db.Build’. From there there is the method getSystem, this returns the OgnlHelper object. This object has a method getExtension that takes the name of our object CoberturaIntegration as a parameter. Now you can call the methods of your own bean which are called via reflection. Now ant knows where to copy the report files to.
The reports are copied to the right place. Now we want to create a link in the build view if the reports are available. Let us have a look at the tapestry code.

  <span jwcid="@Conditional" condition="ognl:build.system.getExtension('CoberturaIntegration').getCoberturaSite(build.publishDir)!=null">
  <span jwcid="@GenericLink" 
    href="ognl:'publish/'+build.schedule.project.name+'/'+build.schedule.name+'/'
      +build.version+ '/'+build.system.getExtension('CoberturaIntegration').
      getCoberturaSite(build.publishDir)" title="cobetura reports">cobertura report</span>
</span>

With the previous explanation you should be able to understand this code. Find the junit link and put it right in front of it. Thats it. Now you should be able to create your own screen like the following.
LuntbuildBuildScreenInclusiveCobertura-1
Finally you are done, cool stuff !

Extending luntbuild ognl possibilities