# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem              1.0
PortGroup               github 1.0
PortGroup               java 1.0

github.setup            ota4j-team opentest4j 1.3.0 r
github.tarball_from     archive
github.livecheck.regex  {([0-9.]+)}

categories              java devel
license                 Apache-2
platforms               any
supported_archs         noarch
maintainers             {sethm.id.au:dev @McDaMastR} \
                        openmaintainer

description             Open Test Alliance for the JVM
long_description        OpenTest4J is a suite of Java exception classes \
                        designed to provide a minimal common foundation for \
                        testing libraries on the JVM.  The primary goal of the \
                        project is to enable testing frameworks and \
                        third-party assertion libraries to use a common set of \
                        exceptions that IDEs and build tools can support in a \
                        consistent manner across all testing scenarios

depends_build-append    port:gradle8
depends_test-append     port:hamcrest \
                        port:junit4

# Building requires Java == 17
# Running requires Java >= 6
java.version            17

set gradle_home         ${workpath}/.home/.gradle

checksums               rmd160  9318269aa04b621c0acfbe18b61b1b4892dbd414 \
                        sha256  8d7f9922c8ec73251e37964a0ea0976546a2fb05133f24dfe0d947e051ff6cb4 \
                        size    89527

patchfiles              use-installed-jars.diff

post-patch {
    reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/build.gradle
}

use_configure           no

build.cmd               gradle8
build.target            build
build.args              --no-daemon \
                        --exclude-task=check \
                        --exclude-task=javadocJar \
                        --exclude-task=sourcesJar \
                        --gradle-user-home="${gradle_home}" \
                        --max-workers=${build.jobs}

test.run                yes
test.target             check
test.args               --no-daemon \
                        --exclude-task=spotlessCheck \
                        --gradle-user-home="${gradle_home}" \
                        --max-workers=${build.jobs}

destroot {
    set destdocdir  ${destroot}${prefix}/share/doc/${name}
    set destjavadir ${destroot}${prefix}/share/java

    xinstall -d ${destjavadir}
    xinstall -W ${worksrcpath} -m 644 \
        build/libs/${name}-${version}.jar \
        ${destjavadir}/${name}.jar

    xinstall -d ${destdocdir}
    xinstall -W ${worksrcpath} -m 644 \
        CONTRIBUTING.md \
        LICENSE \
        README.md \
        ${destdocdir}

    if {[variant_isset doc]} {
        copy ${worksrcpath}/build/docs/javadoc ${destdocdir}
    }
}

variant doc \
        description {Install javadoc} {
    build.target-append javadoc
}
