# -*- 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            ki-shell
version         0.5.2
revision        1

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

description     Kotlin Language Interactive Shell (ki)

long_description The shell is an extensible implementation of Kotlin REPL with reach set of features including: \
                \n\
                \n* Syntax highlight \
                \n* Type inference command \
                \n* Downloading dependencies in runtime using Maven coordinates \
                \n* List declared symbols

homepage        https://github.com/Kotlin/kotlin-interactive-shell
master_sites    https://github.com/Kotlin/kotlin-interactive-shell/releases/download/v${version}/

distname        ki-archive

worksrcdir      ki

checksums       rmd160  3b4577b367997d2b476c9076949f4417d400acfc \
                sha256  9bd5697f9ec29cd63eaf0b503f46edce377bac73e46552aa12231ac5dbda21e4 \
                size    64151230

use_zip         yes
use_configure   no

java.version    1.8+
java.fallback   openjdk11

build {}

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

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

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

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

    # Create launch script
    set launch_script [open ${destroot}${prefix}/bin/ki w 0755]
    puts $launch_script "#!/usr/bin/env bash"
    puts $launch_script "${target}/bin/ki.sh $@"
    close $launch_script
}
