# -*- 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

name                detekt-cli

github.setup        detekt detekt 1.23.7 v
revision            0

# Set the version of the resulting jar. This might be, but is not necessarily identical to ${version}.
set buildversion    ${version}

categories          java devel
license             Apache-2
maintainers         {bochtler.io:macports @MarcelBochtler} \
                    openmaintainer
platforms           darwin
description         CLI tool for detekt
long_description    Detekt is a static code analysis tool for Kotlin.
homepage            https://detekt.github.io

variant formatting description {Include the formatting plugin} {
    build.target-append \
        detekt-formatting:jar
}

github.tarball_from archive

distname            v${version}
checksums           sha256  44e4ba5f2183be39a757358901ed35773f7c0a0b28817fbd7b07b7751aa90517 \
                    rmd160  66858867636df4c28a7b5accdff0548d0e4ebbb1 \
                    size    2026664

java.fallback       openjdk11
java.version        1.8+

use_configure       no

build.env-append    GRADLE_USER_HOME=${worksrcpath}/${name}
build.cmd           ${worksrcpath}/gradlew
build.target        ${name}:shadowJar

destroot {
    set javadir ${destroot}${prefix}/share/java
    xinstall -m 755 -d ${javadir}/${name}
    xinstall -m 644 ${worksrcpath}/${name}/build/libs/${name}-${buildversion}-all.jar ${javadir}/${name}/${name}.jar

    if {[variant_isset formatting]} {
        xinstall -m 644 ${worksrcpath}/detekt-formatting/build/libs/detekt-formatting-${buildversion}.jar ${javadir}/${name}/detekt-formatting.jar
    }

    # Install the wrapper script
    xinstall -m 755 ${filespath}/detekt ${destroot}${prefix}/bin
    reinplace "s|_PREFIX_|${prefix}|g" ${destroot}${prefix}/bin/detekt
}

github.livecheck.regex (\\d+\\.\\d+\\.\\d+)
