#!/bin/bash

echo This batch file will generate Javadoc HTML for each version of the 
echo SuperProduct source code. Then it generates XML from each version, 
echo and finally compares the two XML files to produce an HTML report describing
echo every change in the API between the two releases of SuperProduct.

BASE_URI=http://www.w3.org
# You only need to uncomment this next line and change it to where JDiff 
# lib is installed on your machine if you are not connected to the Internet.
# set BASE_URI=file:////export/home/jdiff/lib

echo Make sure we can find xerces.jar for XML parsing
export CLASSPATH=../../lib/xerces.jar:$CLASSPATH

echo These are the packages in each version of the API
# Coould use the -subpackages option with JDK1.4 to generate these
export OLDPKGS='com.acme.sp com.acme.util'
export NEWPKGS='com.acme.sp com.acme.spextra'

echo 'STEP ONE. Generate Javadoc for the old API (version 1.0 of SuperProduct)'
mkdir -p sample_output/olddocs
cd sample_output/olddocs
javadoc -sourcepath ../../SuperProduct1.0 -doctitle "SuperProduct 1.0 API Documentation" -windowtitle "SuperProduct 1.0 API Documentation" $OLDPKGS
cd ../..

echo 'STEP TWO. Generate Javadoc for the new API (version 2.0 of SuperProduct)'
mkdir -p sample_output/newdocs
cd sample_output/newdocs
javadoc -sourcepath ../../SuperProduct2.0 -doctitle "SuperProduct 2.0 API Documentation" -windowtitle "SuperProduct 2.0 API Documentation"  $NEWPKGS
cd ..

echo STEP THREE. Generate XML for the old API.
javadoc -J-Xmx128m -doclet jdiff.JDiff -docletpath ../../lib/jdiff.jar:../../lib/xerces.jar -apiname "SuperProduct 1.0" -baseURI $BASE_URI -sourcepath ../SuperProduct1.0 $OLDPKGS

echo STEP FOUR. Generate XML for the new API
javadoc -J-Xmx128m -doclet jdiff.JDiff -docletpath ../../lib/jdiff.jar:../../lib/xerces.jar -apiname "SuperProduct 2.0" -baseURI $BASE_URI -sourcepath ../SuperProduct2.0 $NEWPKGS

echo STEP FIVE. Generate HTML report comparing the old and new APIs
javadoc -J-Xmx128m -doclet jdiff.JDiff -docletpath ../../lib/jdiff.jar:../../lib/xerces.jar -d newdocs -stats -oldapi "SuperProduct 1.0" -newapi "SuperProduct 2.0" -javadocold "../../olddocs/" -javadocnew "../../newdocs/" ../../lib/Null.java
cp ../../lib/background.gif newdocs
cp ../../lib/black.gif newdocs/black.gif

cd ..

echo Now open the file sample_output/newdocs/changes.html in a browser
