# -*- 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.5.9
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  ca3385f4cb9f0466c9cc5f35d0baa96f09f905ed \
                sha256  137361c8a25eeabe6f90f435048a698e1c93e5718e0b57069e69f9e2b9ece63c \
                size    28545

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.
"
