# -*- 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
PortGroup       github 1.0

github.setup    kordamp jarviz 0.3.0 v
revision        1

categories      java
platforms       {darwin any}
maintainers     {breun @breun} openmaintainer
license         Apache-2
supported_archs noarch

description     jarviz -- JAR file analyzer

long_description Jarviz is a JAR file analyzer tool. You can obtain metadata \
                from a JAR such as its manifest, manifest entries, bytecode \
                versions, declarative services, Java module descriptors and \
                more.

checksums       rmd160  a75b5a46c978ac1014a9fdf079c9d5bd65e03dd9 \
                sha256  19189b4e24aa494c713dac469da9bab8056f6b70569aa2c459e52f07be4a823d \
                size    584112

use_zip         yes
use_configure   no

# See https://github.com/kordamp/jarviz#stable
java.version    11+
# Latest supported Long Term Support version
java.fallback   openjdk21

build {}

test.run    yes
test.cmd    bin/jarviz
test.target
test.args   --version

destroot {
    set target ${destroot}${prefix}/share/java/${name}

    # Create the target java directory
    xinstall -m 755 -d ${target}

    # Copy over the needed elements of our directory tree
    foreach d { bin lib VERSION } {
        copy ${worksrcpath}/${d} ${target}
    }

    # Remove extraneous bat files
    foreach f [glob -directory ${target}/bin *.bat] {
        delete ${f}
    }

    # Add symlink to the script
    ln -s ../share/java/${name}/bin/jarviz ${destroot}${prefix}/bin

    # Install shell completions
    set comp_path ${destroot}${prefix}/share/bash-completion/completions/${name}
    xinstall -d [file dirname ${comp_path}]
    system -W ${worksrcpath}/bin "./${name} generate-completion > ${comp_path}"
}

notes "
    Bash completion is automatically loaded for bash if bash-completion port is installed.
    To use the port's bash completion script in zsh, add the following command to your .zshrc:

        source ${prefix}/share/bash-completion/completions/${name}

    Or alternatively, add the following to generate completion on launch:

        source <(jarviz generate-completion)
"
