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

github.setup    jenv jenv 0.6.0
revision        0

categories      java
platforms       any
maintainers     {breun @breun} openmaintainer
license         MIT
supported_archs noarch

description     Master your Java environment with jEnv

long_description jEnv is a command line tool to help you forget how to set the JAVA_HOME environment variable.

homepage        https://www.jenv.be
github.tarball_from archive

checksums       rmd160  fb6e9d6c25531cfa453c9056748c27dd0d2c66eb \
                sha256  2897ac544007a2c651bb3c02985143c94f4e1234b9c3c6cb2e436442b17cbc74 \
                size    29630

use_configure   no

build {}

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

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

    # Copy over the files
    foreach d { LICENSE CHANGELOG.md README.md available-plugins bin completions fish libexec } {
        copy ${worksrcpath}/${d} ${target}
    }

    # Add symlink
    ln -s ../share/java/${name}/bin/jenv ${destroot}${prefix}/bin
}

notes "
Add this line to your shell profile (~/.zshrc, ~/.bash_profile) to enable jEnv:

    eval \"\$(jenv init -)\"

Then open a new shell and enable the export plugin:

    jenv enable-plugin export
    exec \$SHELL -l

Optional: install some openjdk* ports if you don't have Java yet:

    sudo port install openjdk11 openjdk17

Add the Java installations to jEnv:

    for d in /Library/Java/JavaVirtualMachines/*/Contents/Home; do jenv add \$d; done

Set a global default Java:

    jenv global 17

Set a local Java version for a specific directory:

    cd /path/to/java/11/project
    jenv local 11

See https://github.com/jenv/jenv for more information.
"
