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

PortSystem          1.0
PortGroup           java 1.0

name                asciidoctorj
version             3.0.1
revision            0

categories          textproc java
license             Apache-2
supported_archs     noarch
platforms           any
maintainers         {judaew @judaew} openmaintainer

description         \
    AsciidoctorJ is the official library for running Asciidoctor on the JVM.
long_description    {*}${description} Using AsciidoctorJ, you can convert \
    AsciiDoc content or analyze the structure of a parsed AsciiDoc document \
    from Java and other JVM languages.
homepage            https://asciidoctor.org

master_sites        https://repo1.maven.org/maven2/org/asciidoctor/asciidoctorj/${version}/
distname            ${name}-${version}-bin
worksrcdir          ${name}-${version}

checksums           rmd160  0c5774e9640a57e2ef93db00dfd5ae95fc1e2bcf \
                    sha256  18b085b7f67a7f872abe00352be5caacd9b436400aec27f838c6380077cb88bf \
                    size    76713527

java.version        1.8+
java.fallback       openjdk11

use_zip             yes
use_configure       no
build {}

post-patch {
    # set APP_HOME to ${prefix}
    reinplace "s|APP_HOME=\"\\`pwd -P\\`\"|APP_HOME=\"@@PREFIX@@\"|" \
        ${worksrcpath}/bin/asciidoctorj
    # remove /lib/ from path to use just a prefix
    reinplace "s|\\\$APP_HOME/lib/|\\\$APP_HOME/|g" \
        ${worksrcpath}/bin/asciidoctorj
}

destroot {
    delete ${worksrcpath}/bin/${name}.bat

    reinplace "s,@@PREFIX@@,${prefix}/lib/${name},g" ${worksrcpath}/bin/${name}
    xinstall -m 0755 ${worksrcpath}/bin/${name} ${destroot}${prefix}/bin

    xinstall -m 0755 -d ${destroot}${prefix}/lib/asciidoctorj
    xinstall -m 0644 {*}[glob ${worksrcpath}/lib/*.jar] \
        ${destroot}${prefix}/lib/asciidoctorj
}

livecheck.type      regex
livecheck.url       https://repo1.maven.org/maven2/org/asciidoctor/asciidoctorj/maven-metadata.xml
livecheck.regex     >(\\d+\\.\\d+(\\.\\d+)*)</
