# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: Lukas Fleischer <lfleischer@archlinux.org>
# Contributor: Stefan Husmann <stefan-husmann@t-online.de>
# Contributor: Simon Lipp <sloonz+aur@gmail.com>

pkgname=fop
pkgver=2.10
pkgrel=1
pkgdesc='XSL-FO to PDF formatter'
arch=(any)
url='https://xmlgraphics.apache.org/fop/'
license=(Apache-2.0)
depends=(java-avalon-framework 'java-batik=1.17' java-commons-io java-commons-logging java-xmlgraphics-commons)
makedepends=(apache-ant jdk8-openjdk maven)
source=("https://dlcdn.apache.org/xmlgraphics/$pkgname/source/$pkgname-$pkgver-src.tar.gz"
        fop.conf)
b2sums=('5217edbabc255b2e37c6198ea7cdfb1344db0726c7156f73bdc5ac452c4c233c5280d263e65656cde92ce6aa52c8ea94e346d9d14535ca802fc37fe1475ba255'
        '928ced5f2591d2537829d74ae94c6f59e1be2f12eddf44e2f7fe5fd06606e94a5911396d6ef8596137449524c9d0d13ef8896bc4fb5e58096bd9948708879857')
backup=(etc/fop.conf)

prepare() {
  cd $pkgname-$pkgver/$pkgname
  cp -f "$srcdir/fop.conf" fop.conf
  pacman -Ql java-batik | grep \.jar | sed 's/java-batik /CLASSPATH="$CLASSPATH:/g;s/$/"/g' >> fop.conf
}

build() {
  export JAVA_HOME=/usr/lib/jvm/java-8-openjdk
  cd $pkgname-$pkgver
  ant -f $pkgname/build.xml package
}

package() {
  cd $pkgname-$pkgver/$pkgname
  install -Dm755 -t "$pkgdir/usr/bin" $pkgname
  install -Dm644 -t "$pkgdir/usr/share/java/fop" build/fop.jar
  install -Dm644 -t "$pkgdir/etc" fop.conf
}
