Ant task usage

To use JarDiff from an ant build script, is relatively trivial, here is an example:

<project name="jardiff" default="jardiff" basedir=".">

  <!-- Lib directory (this is where your jar files live) -->
  <property name="lib" value="libs"/>
  <!-- Classpath for jardiff -->
  <property name="jardifflibs" value="${lib}/jardiff-0.2.jar:${lib}/asm-2.1.jar:${lib}/asm-commons-2.1.jar"/>
  <!-- Define jardiff and jdxslt tasks from properties file in jar -->
  <typedef resource="ant/jardiff.properties" classpath="${jardifflibs}"/>
  <!-- Location of jardiff xslt stylesheets -->
  <whichresource classpath="${jardifflibs}" property="jardiff-html" resource="style/jardiff-html.xsl"/>
  <whichresource classpath="${jardifflibs}" property="jardiff-xhtml" resource="style/jardiff-xhtml.xsl"/>
  <whichresource classpath="${jardifflibs}" property="jardiff-text" resource="style/jardiff-text.xsl"/>


  <target name="jardiff">
    <jardiff fromjar="jardiff-0.1.jar" tojar="jardiff-0.2.jar" 
      out="jardiff-0.1-0.2.xml"/>
    <jdxslt in="jardiff-0.1-0.2.xml" out="jardiff-0.1-0.2.html" styleurl="${jardiff-xhtml}">
      <param name="stylesheet" expression="diff.css"/>
      <param name="from-api" 
        expression="http://dist.osjava.org/releases/multidoc-jnr/jardiff/0.1"/>
      <param name="to-api" 
        expression="http://dist.osjava.org/releases/multidoc-jnr/jardiff/0.2"/>
    </jdxslt>
  </target>

</project>

There is a fully functional ant build script in src/examples in the distribution.

Jardiff Task

The jardiff task generates an xml document describing the changes between two jar files.

The jardiff task takes the following options:

AttributeTypeMeaningRequireddefault
fromjarfileFrom jar fileYesnone
tojarfileTo jar fileYesnone
outfileOutput xml fileYesnone
fromnamestringName of from versionNofromjar filename
tonamestringName of to versionNotojar filename
forcebooleanOverwrite output file if it already exists, and is newer than both source jar files.NoNo

Jdxslt Task

The jdxslt task is an extension of the built in and xslt task, which allows a stylesheet to be specified as a URL (in the example, we use an xslt contained in the jardiff jar file, which can be resolved to a url, and then passed into an xslt task as the style).

It is fine to use the built in ant xslt task, as the only modification I made was to allow specifying the stylesheet as a url, as I see no reason to have to extract a stylesheet from a jarfile before using it.

The jdxslt task takes exactly the same arguments as the xslt core task with the following modifications.

AttributeTypeMeaningRequireddefault
stylefileStylesheet to useYes, or styleurlnone
styleurlstringURL of stylesheet to useYes, or stylenone