# -*- 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           java 1.0

name                xercesj
version             2.12.2
revision            1

categories          java textproc
license             Apache-2
platforms           any
supported_archs     noarch
homepage            https://xerces.apache.org/xerces2-j
maintainers         {sethm.id.au:dev @McDaMastR} \
                    openmaintainer

description         Apache Xerces2 Java XML Parser
long_description    Xerces2 Java is the reference implementation of the Xerces \
                    Native Interface (XNI), a complete framework for building \
                    XML parser components and configurations.  The parser \
                    supports XML 1.0 and 1.1, DOM, JAXP, SAX, and XInclude.

depends_build-append \
                    bin:ant:apache-ant

java.version        1.8+

master_sites        apache:xerces/j/source/
distname            Xerces-J-src.${version}
distfiles           ${distname}${extract.suffix} \
                    Xerces-J-tools.${version}${extract.suffix}
worksrcdir          xerces-[string map {. _} ${version}]

checksums           ${distname}${extract.suffix} \
                        rmd160  2a7227d1babca9acd62fa2dac8896f6650069f2f \
                        sha256  6dd1ebd4c88e935c182375346cd7365514bd8dd2ad2f30f0d0b05257bab34ee8 \
                        size    1812583 \
                    Xerces-J-tools.${version}${extract.suffix} \
                        rmd160  60cce241c67b34eb678c9e0232551e3677017054 \
                        sha256  66b88ccbbba507f9f9cffb285a94258cd9fb6a842dfbeb8499866b156021a574 \
                        size    7074111

post-extract {
    move ${workpath}/tools ${worksrcpath}
}

use_configure       no

build.cmd           ant
build.target        jars jars-schema11
build.args          -Djavac.source=1.8 \
                    -Djavac.target=1.8

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

    xinstall -d ${destjavadir}
    xinstall -m 644 \
        ${worksrcpath}/build/schema11-xercesImpl.jar \
        ${worksrcpath}/build/xercesImpl.jar \
        ${worksrcpath}/build/xml-apis.jar \
        ${destjavadir}

    xinstall -d ${destdocdir}
    xinstall -m 644 \
        ${worksrcpath}/README \
        {*}[glob -directory ${worksrcpath} LICENSE*] \
        {*}[glob -directory ${worksrcpath} NOTICE*] \
        ${destdocdir}

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

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

livecheck.type      regex
livecheck.url       https://downloads.apache.org/xerces/j/source/
livecheck.regex     "Xerces-J-src\\.(\[0-9]+(\\.\[0-9]+)*)\\.tar\\.gz"
