# -*- 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                xml-commons-resolver
version             1.2

categories          java devel
license             Apache-2
platforms           any
supported_archs     noarch
maintainers         nomaintainer

description         Java library for XML entity resolution
long_description    It is very common for web resources to be related to other resources. These \
                    relationships are expressed using URIs, most often URLs. Relying on URLs to \
                    directly identify resources to be retrieved often causes problems for end \
                    users. One way to avoid these problems is to use an entity resolver (a standard \
                    part of SAX) or a URI Resolver (a standard part of JAXP). A resolver can examine \
                    the URIs of the resources being requested and determine how best to satisfy \
                    those requests. The best way to make this function in an interoperable way is to \
                    define a standard format for mapping system identifiers and URIs. These "catalog \
                    files" can be used to map public and system identifiers and other URIs to local \
                    files (or just other URIs). The XML Commons Resolver classes greatly simplify \
                    the task of using catalog files to perform entity resolution.
homepage            https://xerces.apache.org/xml-commons/components/resolver

master_sites        apache:xerces/xml-commons

checksums           rmd160  b4e9ac205e62a5bb97d23424a3aedeb70aa1908a \
                    sha256  55dbe7bd56452c175320ce9a97b752252c5537427221323c72e9b9c1ac221efe \
                    size    262701

depends_build       bin:ant:apache-ant

java.version        1.8+
java.fallback       openjdk11

patchfiles          specify-java-version.diff

post-patch {
    reinplace "s|@@JAVA_VERSION@@|1.8|g" ${worksrcpath}/resolver.xml
}

use_configure       no

build.cmd           ant
build.target        jar
build.args          -f resolver.xml

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

    xinstall -d ${destjavadir}
    xinstall -m 644 \
        ${worksrcpath}/build/resolver.jar \
        ${destjavadir}

    xinstall -d ${destdocdir}
    xinstall -m 644 \
        ${worksrcpath}/LICENSE.resolver.txt \
        ${worksrcpath}/NOTICE-resolver.txt \
        ${worksrcpath}/build/manifest.resolver \
        ${destdocdir}

    if {[variant_isset doc]} {
        xinstall -m 644 \
            {*}[glob -directory ${worksrcpath}/docs *] \
            ${destdocdir}
        copy \
            ${worksrcpath}/apidocs \
            ${destdocdir}
    }
}

variant doc \
        description {Install documentation} {
    # Install pre-built documentation.
    # Building htmldocs assumes files not included in distfile.
    # Building javadocs fails with invalid HTML errors.
}

livecheck.type      regex
livecheck.url       https://downloads.apache.org/xerces/xml-commons/
livecheck.regex     "${name}-(\[0-9]+(\\.\[0-9])*)(-\[a-z]+)*\\.tar\\.gz"
