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

pkgname=ditaa
pkgver=0.10
pkgrel=1.parabola1
pkgdesc='Java utility to convert diagrams drawn using ascii art to bitmap'
arch=('any')
url='https://github.com/stathissideris/ditaa'
license=('LGPL')
depends=('java-environment' 'java-commons-cli' 'jericho-html' 'gsfonts')
makedepends=('git' 'apache-ant' 'java-commons-cli' 'java-batik' 'jericho-html')
source=("git://github.com/stathissideris/ditaa#tag=v$pkgver"
        'ditaa.sh' 'ditaa-fix_imports.patch' 'ditaa-usage_message.patch'
        'ditaa-HTMLConverter.patch')
sha256sums=('SKIP'
            '5372004969ae1449fc5dc8eec55dc6970a383169bf9c26be04f6e3ae277c7038'
            '74a0b7df6865499a25792d981106b669cc51874e673dd621761c30c462fe8deb'
            '62493fd286d1d80dd96064266bd579c661bbd04409ac448b3ba680e34faeaa56'
            '8b44c563d4e2d62806e25c3fa6d91b676f388caeb7f819d8d8fec02153f9aa3d')

prepare() {
  cd "$srcdir/$pkgname"
  rm -v lib/*.jar
  rm -v web/lib/*.jar
  mkdir -p bin
  patch -Np1 -i "$srcdir/ditaa-fix_imports.patch"
  patch -Np1 -i "$srcdir/ditaa-usage_message.patch"
  patch -Np1 -i "$srcdir/ditaa-HTMLConverter.patch"
}

build() {
  cd "$srcdir/$pkgname"
  ant -f build/release.xml release-jar \
    -Dversion.string=$pkgver \
    -lib "/usr/share/java/batik-anim.jar" \
    -lib "/usr/share/java/batik-awt-util.jar" \
    -lib "/usr/share/java/batik-bridge.jar" \
    -lib "/usr/share/java/batik-codec.jar" \
    -lib "/usr/share/java/batik-dom.jar" \
    -lib "/usr/share/java/batik-gvt.jar" \
    -lib "/usr/share/java/batik-svg-dom.jar" \
    -lib "/usr/share/java/commons-cli.jar" \
    -lib "/usr/share/java/jericho-html.jar" \
    -lib "/usr/share/java/xml-apis-ext.jar"
}

package() {
  cd "$srcdir/$pkgname"
  install -Dm644 COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING"
  install -Dm755 "releases/$pkgname$pkgver.jar" \
    "$pkgdir/usr/share/java/$pkgname/$pkgname-$pkgver.jar"
  ln -s "/usr/share/java/$pkgname/$pkgname-$pkgver.jar" \
    "$pkgdir/usr/share/java/$pkgname.jar"
  install -Dm755 "$srcdir/$pkgname.sh" "$pkgdir/usr/bin/$pkgname"
}
