# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>

pkgname=docbook-xsl-saxon
pkgver=1.00
pkgrel=3.parabola1
pkgdesc="Java extensions for use with the DocBook XML stylesheets and the Saxon XSLT engine"
arch=('any')
url="http://docbook.sourceforge.net/"
license=('custom:MIT')
depends=('java-runtime' 'docbook-xsl' 'saxon6')
makedepends=('apache-ant' 'saxon6' 'jh')
source=("http://sourceforge.net/projects/docbook/files/${pkgname}/${pkgver}/${pkgname}-${pkgver}.tar.bz2"
        'pom.xml')
sha1sums=('cb2069bcfd81cfa272ef14d97de7ec2cc099ffe4'
          '5bdd221ecbc90a508dc213dbfa73de92db928fa7')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  rm -rv *.jar
  rm -rv {classes,javadoc}
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ant \
    -Dplatform.active=parabola \
    -Dplatforms.parabola.home=/usr/lib/jvm/default \
    -Djavac.classpath=/usr/share/java/saxon.jar \
    -Ddist.jar=${pkgname}.jar
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  # Install license file
  install -Dm644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/COPYING"

  # Install documentation
  install -d "${pkgdir}/usr/share/doc/${pkgname}"
  cp -r javadoc "${pkgdir}/usr/share/doc/${pkgname}"

  # Install Maven artifacts
  export DESTDIR=${pkgdir}
  jh mvn-install net.sf.docbook ${pkgname} ${pkgver} \
    "${srcdir}/pom.xml" \
    "${pkgname}.jar" \
    "${pkgname}-${pkgver}.jar"
  ln -s "/usr/share/java/${pkgname}-${pkgver}.jar" \
    "${pkgdir}/usr/share/java/${pkgname}.jar"
}
