Chapter 5. Integrating with Ant

The provided SonargraphReportTask makes it easy to integrate SonargraphBuild into Apache Ant based builds and generate HTML or XML reports containing info about metrics and issues of a software system. Additionally, using the optional "failSet" element, the Ant build can be marked as failed if certain issues exist.

Prerequisites:

  1. You need at least Ant 1.8.3 installed.

  2. Set the environment variable ANT_HOME.

  3. Include ANT_HOME/bin in your PATH environment variable.

The following shows the SonargraphReportTask definition:

<taskdef name="sonargraphBuild" 
     classname="com.hello2morrow.sonargraph.build.client.ant.SonargraphReportTask">
  <classpath>
    <fileset dir="${sonargraph.build.installation}/plugins">
      <include name="org.eclipse.osgi_3.1*.jar" />
      <include name="com.hello2morrow.sonargraph.build.client*.jar"/>
    </fileset>
    <fileset dir="${sonargraph.build.installation}/client" includes="*.jar" />
  </classpath>
</taskdef>

An example Ant build.xml is provided in the directory <inst-dir>/example/ant. The parameters are the same as for the shell integration described in Chapter 4, Executing from the Command-line