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

github.setup        JetBrains kotlin 2.4.10 v
revision            0
github.tarball_from releases
distname            ${name}-compiler-${version}
categories          lang java
platforms           {darwin any}
maintainers         {breun @breun} openmaintainer
license             Apache-2

description         Statically typed programming language for the JVM, \
                    Android and the browser

long_description    Kotlin is a modern but already mature programming \
                    language aimed to make developers happier. It's \
                    concise, safe, interoperable with Java and other \
                    languages, and provides many ways to reuse code \
                    between multiple platforms for productive programming.

homepage            https://kotlinlang.org/

checksums           rmd160  85fce2d29c98c99c0d89e337d3adee1ac22cdae7 \
                    sha256  473dd66c7a3ef4b182065b3da670466c1bf2773a9dbb0ed8b33a39fe9d4f876d \
                    size    87077443

java.version        1.8+
java.fallback       openjdk25

worksrcdir          kotlinc

use_zip             yes
use_configure       no

build {}

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

pre-destroot {
    delete {*}[glob ${worksrcpath}/bin/*.bat]
}

destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/java
    file copy ${worksrcpath} \
         ${destroot}${prefix}/share/java/${name}
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/
    file rename ${destroot}${prefix}/share/java/${name}/license \
        ${destroot}${prefix}/share/doc/${name}

    foreach f [glob -tails -directory ${destroot}${prefix}/share/java/${name}/bin *] {
        ln -s ../share/java/${name}/bin/${f} ${destroot}${prefix}/bin/${f}
    }
}

supported_archs     noarch

livecheck.type      regex
livecheck.url       https://github.com/JetBrains/kotlin/releases/latest
livecheck.regex     ${name}-compiler-(\\d+\\.\\d+\\.\\d+).zip
