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

github.setup        swagger-api swagger-codegen 3.0.36 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
categories          devel
license             Apache-2
platforms           any
maintainers         nomaintainer
supported_archs     noarch

description         Generates API client libraries (SDK generation), server stubs \
                    and documentation automatically given an OpenAPI Spec

long_description    {*}${description}

homepage            https://swagger.io/tools/swagger-codegen/
master_sites        https://repo1.maven.org/maven2/io/swagger/codegen/v3/${name}-cli/${version}/
distfiles           ${name}-cli-${version}.jar

checksums           rmd160  37af728046c9fd9a161a66ef4b158cbd0517c1a7 \
                    sha256  9c9b23193b5333d663b2a64228a645acb3d9e23229d45d12a62e91cdeb82cda9 \
                    size    21906448

java.version        1.8+

use_configure       no
# don't extract anything
extract.only

build {}

set javadir         ${prefix}/share/java

destroot {
    xinstall -m 0755 -d ${destroot}${javadir}/${name}
    copy ${distpath}/${distfiles} ${destroot}${javadir}/${name}/${name}-cli.jar

    set fp [open ${destroot}${prefix}/bin/${name} w]
    puts $fp "#!/bin/sh"
    puts $fp "exec java -jar ${javadir}/${name}/${name}-cli.jar \"$@\""
    close $fp
    system "chmod +x ${destroot}${prefix}/bin/${name}"
}
