# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=recaf
pkgver=2.8.0.1992.355d31a0
pkgrel=1
groups=('blackarch' 'blackarch-decompiler' 'blackarch-reversing')
pkgdesc='Modern Java bytecode editor.'
arch=('any')
url='https://github.com/Col-E/Recaf'
license=('MIT')
depends=('java-runtime' 'java-environment')
makedepends=('maven' 'git' 'jdk-openjdk')
source=("$pkgname::git+https://github.com/Col-E/Recaf.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git describe --tags).$(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

build() {
  cd $pkgname

  # https://github.com/Col-E/Recaf/blob/master/build
  mvn package -Dmaven.test.skip -Dcheckstyle.skip -P java11
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  cp target/recaf-*-jar-with-dependencies.jar \
    "$pkgdir/usr/share/$pkgname/$pkgname.jar"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
java -jar /usr/share/$pkgname/$pkgname.jar "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

