# Maintainer: Parabola Hackers <dev@lists.parabola.nu>

pkgname=opentest4j
pkgver=1.2.0
pkgrel=1
pkgdesc='Minimal common foundation for testing libraries for Java'
arch=('any')
url='https://github.com/ota4j-team/opentest4j'
license=('Apache')
depends=('java-environment' 'java-runtime')
makedepends=('jh')
source=("https://github.com/ota4j-team/${pkgname}/archive/refs/tags/r${pkgver}.tar.gz")
sha512sums=('cd98d976935de97d259ec4c04510334f2b56f8a32db2c97e0f20a2e3b99f119ffeb390589eb42d4594808d96194067871d5eaad6a40dd58af30b9f995b13ef08')

prepare() {
  cd "${srcdir}/${pkgname}-r${pkgver}"
  mkdir -p "${srcdir}/dist/classes"
  mkdir -p "${srcdir}/dist/source"
}

build() {
    cd "${srcdir}/${pkgname}-r${pkgver}"

    javac \
        -classpath "${CLASSPATH}" \
        -d "classes" \
        -encoding UTF-8 \
        $(find "src/main/java/" -name \*.java)
    
    jar -cvf "${pkgname}.jar" \
        -C "classes" .

    javadoc \
        -d "build/javadoc" \
        -encoding UTF-8 \
        -sourcepath "src/main/java" \
        org.opentest4j
}

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

    # CONTRIBUTING.md has the project license statement:
    # **Project License:** [Apache License Version 2.0](LICENSE)
    install -Dm644 \
	    LICENSE CONTRIBUTING.md \
            -t "${pkgdir}/usr/share/licenses/${pkgname}/"

    export DESTDIR="$pkgdir"
    jh mvn-install ${pkgname} ${pkgname} ${pkgver} \
       pom.xml \
       "${pkgname}.jar" \
       "${pkgname}.jar"

    ln -s "/usr/share/java/${pkgname}.jar" \
       "${pkgdir}/usr/share/java/${pkgname}-${pkgver}.jar"
}
