# Maintainer (Arch): Guillaume ALAUX <guillaume@archlinux.org>
# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>

_libname=commons-net
pkgname=java-${_libname}1
pkgver=1.4.1
pkgrel=3.parabola1
pkgdesc="Apache library that implements the client side of many basic Internet protocols"
arch=('any')
url="http://commons.apache.org/net/"
license=('APACHE')
depends=('java-runtime-headless')
makedepends=('apache-ant' 'jakarta-oro' 'jh')
source=("https://archive.apache.org/dist/commons/net/source/${_libname}-${pkgver}-src.tar.gz")
sha512sums=('6ac697536eff947cd0aa828c887e9cc4046c49a593c760bbc59db7e04cf0d7456e84d22504cfa2f6915315dc061e3499382f05bd7740bf79a532a4d9d42c0da8')

build() {
  cd "${srcdir}/${_libname}-${pkgver}"
  ant dist -Dnoget=true -lib "/usr/share/java/jakarta-oro.jar"
}

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

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

  # Install documentation
  install -d "${pkgdir}/usr/share/doc/${pkgname}"
  cp -r "dist/docs/api" "${pkgdir}/usr/share/doc/${pkgname}"
  cp -r "src/java/examples" "${pkgdir}/usr/share/doc/${pkgname}/examples"

  # Install Maven artifacts
  export DESTDIR=${pkgdir}
  jh mvn-install ${_libname} ${_libname} ${pkgver} \
    "${srcdir}/${_libname}-${pkgver}/project.xml" \
    "${srcdir}/${_libname}-${pkgver}/target/${_libname}-${pkgver}.jar" \
    "${_libname}.jar"
  ln -s "/usr/share/java/${_libname}.jar" \
    "${pkgdir}/usr/share/java/${_libname}-${pkgver}.jar"
}
