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

_pkgname=commons-codec
pkgname=java-${_pkgname}
pkgver=1.10
pkgrel=1
pkgdesc="Encoder and decoders such as Base64 and hexadecimal codec"
arch=('any')
url="http://commons.apache.org/codec/"
license=('APACHE')
depends=('java-runtime')
makedepends=('apache-ant' 'jh')
source=("http://archive.apache.org/dist/commons/codec/source/${_pkgname}-${pkgver}-src.tar.gz")
md5sums=('ea7c015a2c7b641cd11298ed94d992c7')

prepare() {
  cd "${srcdir}/${_pkgname}-${pkgver}-src"
  sed -i 's/1\.9/1\.10/g' default.properties
}

build() {
  cd "${srcdir}/${_pkgname}-${pkgver}-src"
  ant dist
}

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

  # 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}"

  # Install Maven artifacts
  export DESTDIR=${pkgdir}
  jh mvn-install ${_pkgname} ${_pkgname} ${pkgver} \
    "${srcdir}/${_pkgname}-${pkgver}-src/pom.xml" \
    "${srcdir}/${_pkgname}-${pkgver}-src/dist/${_pkgname}-${pkgver}-SNAPSHOT.jar" \
    "${_pkgname}.jar"
  ln -s "/usr/share/java/${_pkgname}.jar" \
    "${pkgdir}/usr/share/java/${_pkgname}-${pkgver}.jar"
}