#! /bin/sh

# A convenient way to call the main() method of a class
# in findbugs.jar.

spotbugs_home=/usr/share/spotbugs
fb_osname=`uname`

if [ ! -d "$spotbugs_home" ]; then
	echo "The path $spotbugs_home,"
	echo "which is where I think SpotBugs is located,"
	echo "does not seem to be a directory."
	exit 1
fi

# Choose default java binary
fb_javacmd=java
if [ ! -z "$JAVA_HOME" ] && [ -x "$JAVA_HOME/bin/java" ]; then
	fb_javacmd="$JAVA_HOME/bin/java"
fi

if [ $# -eq 0 ]; then
	echo "Usage: fbwrap <main class name> <args...>"
	exit 1
fi

fb_mainclass="$1"
shift

fb_javacmd=${fb_javacmd:-"java"}
fb_maxheap=${fb_maxheap:-"-Xmx768m"}
fb_classpath=$spotbugs_home/lib/config:$(build-classpath spotbugs)
if [ -n "$CLASSPATH" ]; then
	fb_classpath+=":$CLASSPATH"
fi
set -f
exec "$fb_javacmd" \
	-classpath "$fb_classpath" \
	-Dspotbugs.home="$spotbugs_home"\
	$fb_maxheap $fb_jvmargs $fb_mainclass ${@:+"$@"} $fb_appargs

# vim:ts=3
