Topics to talk about at FOSDEM 2010 regarding Debian-Java:

Best Practices

(un)linkjars

Most upstream tarballs include convenience copies of dependency jars. These can not be used to build debian packages. To avoid patching the upstream build.xml one can also link the required jar files from /usr/share/java to the directories where upstream expects them.

The following snippets help with linking and unlinking the jars. They link only those jars defined in debian/control#Build-Depends and thus also help to get the build depends right. I'd propose to include these snippets in the javahelper package or somewhere alike.

# script to link required jar files from /usr/share/java

DESTINATION=$1

if [ -z $DESTINATION ]
then
  echo "missing destination"
  exit 1
fi

BUILDDEPENDS=$(grep-dctrl --no-field-names --show-field Build-Depends -F source zookeeper debian/control | tr " ," "\n" | grep -v "^$" )

for DEPENDENCY in $BUILDDEPENDS
do
  echo "linking .jar files of $DEPENDENCY:"
  JARS=$(dpkg -L $DEPENDENCY | grep "^/usr/share/java/.*\.jar$")
  for JAR in $JARS
  do
    echo "  link $JAR"
    ln -s $JAR $DESTINATION
  done
done

# debian/rules file using the above script

linkjars:
        dh_testdir
        debian/linkjars.sh lib
        debian/linkjars.sh src/java/lib

unlinkjars:
        dh_testdir
        find lib -lname "/usr/share/java/*.jar" -exec rm {} \;
        find src/java/lib -lname "/usr/share/java/*.jar" -exec rm {} \;


FOSDEM slides CategoryJava