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

name             openjdk8
version          8u232
revision         0

set build        09
set major        8

subport openjdk8-graalvm {
    version      19.3.0
    revision     0

    set major    8
}

subport openjdk8-openj9 {
    version      8u232
    revision     1

    set build    09
    set major    8
    set openj9_version 0.17.0
}

subport openjdk8-openj9-large-heap {
    version      8u232
    revision     1

    set build    09
    set major    8
    set openj9_version 0.17.0
}

subport openjdk10 {
    version      10.0.2
    revision     2
    
    set build    13
    set major    10
}

subport openjdk11 {
    version      11.0.5
    revision     0

    set build    10
    set major    11
}

subport openjdk11-graalvm {
    version      19.3.0
    revision     0

    set major    11
}

subport openjdk11-openj9 {
    version      11.0.5
    revision     1

    set build    10
    set major    11
    set openj9_version 0.17.0
}

subport openjdk11-openj9-large-heap {
    version      11.0.5
    revision     1

    set build    10
    set major    11
    set openj9_version 0.17.0
}

subport openjdk12 {
    version      12.0.2
    revision     0

    set build    10
    set major    12
}

subport openjdk12-openj9 {
    version      12.0.2
    revision     0

    set build    10
    set major    12
    set openj9_version 0.15.1
}

subport openjdk12-openj9-large-heap {
    version      12.0.2
    revision     0

    set build    10
    set major    12
    set openj9_version 0.15.1
}

subport openjdk13 {
    version      13.0.1
    revision     0

    set build    9
    set major    13
}

subport openjdk13-openj9 {
    version      13.0.1
    revision     1

    set build    9
    set major    13
    set openj9_version 0.17.0
}

subport openjdk13-openj9-large-heap {
    version      13.0.1
    revision     1

    set build    9
    set major    13
    set openj9_version 0.17.0
}

categories       java devel
maintainers      {breun.nl:nils @breun} openmaintainer
platforms        darwin
license          GPL-2
supported_archs  x86_64

description      Open Java Development Kit ${major} (AdoptOpenJDK) with HotSpot VM

long_description OpenJDK build provided by AdoptOpenJDK, built from a fully \
                 open-source set of build scripts and infrastructure. \
                 \
                 HotSpot is the VM from the OpenJDK community and  the most widely used VM. \
                 It is suitable for all workloads.

homepage         https://adoptopenjdk.net/

if {${subport} eq "openjdk8"} {
    livecheck.url    https://api.adoptopenjdk.net/v2/info/releases/${subport}?release=latest&openjdk_impl=hotspot
    livecheck.regex  {"release_name": "jdk(\d+u\d+)-b\d+"}
} else {
    livecheck.url    https://github.com/AdoptOpenJDK/openjdk-jdk${major}u/releases
    livecheck.regex  (?c)jdk-(\[0-9.\]+)
}

if {${subport} eq "openjdk8"} {
    master_sites https://github.com/AdoptOpenJDK/openjdk${major}-binaries/releases/download/jdk${version}-b${build}/
    
    checksums    rmd160  c659d3f0f5611aa03859fb9442b6eca138485788 \
                 sha256  c237b2c2c32c893e4ee60cdac8c4bcc34ca731a5445986c03b95cf79918e40c3 \
                 size    102496705

    distname     OpenJDK${major}U-jdk_x64_mac_hotspot_${version}b${build}
    worksrcdir   jdk${version}-b${build}

    configure.cxx_stdlib libstdc++
} elseif {${subport} eq "openjdk8-graalvm"} {
    master_sites https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${version}/
    distname     graalvm-ce-java${major}-darwin-amd64-${version}
    worksrcdir   graalvm-ce-java${major}-${version}

    checksums    rmd160  0d6e88a4a9227ab7a515d84409b4f279d4a6a016 \
                 sha256  6c43063148368dc537a58706fcbf332583371ebb32dfdb78017e6a80e139658b \
                 size    356582812

    description  GraalVM Community Edition based on OpenJDK ${major}
    long_description GraalVM is a universal virtual machine for running applications written in JavaScript, Python, \
                 Ruby, R, JVM-based languages like Java, Scala, Groovy, Kotlin, Clojure, and LLVM-based languages \
                 such as C and C++.

    homepage     https://www.graalvm.org
} elseif {${subport} eq "openjdk8-openj9"} {
    master_sites https://github.com/AdoptOpenJDK/openjdk${major}-binaries/releases/download/jdk${version}-b${build}.${revision}_openj9-${openj9_version}/
    # Temporary dist_subdir for stealth update: https://trac.macports.org/wiki/PortfileRecipes#stealth-updates
    dist_subdir  ${name}/${version}_${revision}

    checksums    rmd160  d90d77e1ee0d2752f992ba8a53dbcad9602e191d \
                 sha256  168079dcc20f62ac4409800c78d23a63ba7c665e58cd7ac8bde21ebbbb2b6d48 \
                 size    114222397

    distname     OpenJDK${major}U-jdk_x64_mac_openj9_${version}b${build}_openj9-${openj9_version}
    worksrcdir   jdk${version}-b${build}

    description  Open Java Development Kit ${major} (AdoptOpenJDK) with Eclipse OpenJ9 VM
    long_description AdoptOpenJDK provides prebuilt OpenJDK binaries from a fully \
                 open-source set of build scripts and infrastructure. \
                 \
                 OpenJ9 is the virtual machine from the Eclipse community. It is an enterprise-grade \
                 VM designed for low memory usage and fast start-up and is used in IBM’s JDK. It is \
                 suitable for running all workloads.
} elseif {${subport} eq "openjdk8-openj9-large-heap"} {
    master_sites https://github.com/AdoptOpenJDK/openjdk${major}-binaries/releases/download/jdk${version}-b${build}.${revision}_openj9-${openj9_version}/
    # Temporary dist_subdir for stealth update: https://trac.macports.org/wiki/PortfileRecipes#stealth-updates
    dist_subdir  ${name}/${version}_${revision}

    checksums    rmd160  5b541680f690a2eb353c764dba8c5ddf62f8f366 \
                 sha256  e28e308321886fe98caada4148a6ee768b22e97486696220ffde6c174fe75fa9 \
                 size    114212346

    distname     OpenJDK${major}U-jdk_x64_mac_openj9_macosXL_${version}b${build}_openj9-${openj9_version}
    worksrcdir   jdk${version}-b${build}

    description  Open Java Development Kit ${major} (AdoptOpenJDK) with Eclipse OpenJ9 VM for large heap sizes
    long_description AdoptOpenJDK provides prebuilt OpenJDK binaries from a fully \
                 open-source set of build scripts and infrastructure. \
                 \
                 OpenJ9 is the virtual machine from the Eclipse community. It is an enterprise-grade \
                 VM designed for low memory usage and fast start-up and is used in IBM’s JDK. It is \
                 suitable for running all workloads. \
                 \
                 This version uses non-compressed references and should be used for applications which require heaps that are over ~57 GB.
} elseif {${subport} eq "openjdk10"} {
    master_sites https://download.java.net/java/GA/jdk${major}/${version}/19aef61b38124481863b1413dce1855f/${build}/

    checksums    rmd160  d29498411adc487bf8191adbc4276c72602022cf \
                 sha256  77ea7675ee29b85aa7df138014790f91047bfdafbc997cb41a1030a0417356d7 \
                 size    200916897

    distname     openjdk-${version}_osx-x64_bin
    worksrcdir   jdk-${version}.jdk

    description  Oracle OpenJDK ${major} with HotSpot VM
    long_description Production-ready, free and open-source build of the Java \
                 Development Kit, an implementation of the Java Standard \
                 Edition (SE) ${major} Platform. OpenJDK is the official reference \
                 implementation of Java SE. Included components are the \
                 HotSpot virtual machine, the Java class library and the Java \
                 compiler.

    homepage     https://jdk.java.net/${major}/
} elseif {${subport} eq "openjdk11"} {
    master_sites https://github.com/AdoptOpenJDK/openjdk${major}-binaries/releases/download/jdk-${version}%2B${build}/

    checksums    rmd160  d4099ff93dce27338c2675b356e4f2859082bf8e \
                 sha256  0825d0d3177832320b697944cd8e7b2e7fe3893fafe8bfcf33ee3631aa5ca96b \
                 size    188745854

    distname     OpenJDK${major}U-jdk_x64_mac_hotspot_${version}_${build}
    worksrcdir   jdk-${version}+${build}
} elseif {${subport} eq "openjdk11-graalvm"} {
    master_sites https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${version}/
    distname     graalvm-ce-java${major}-darwin-amd64-${version}
    worksrcdir   graalvm-ce-java${major}-${version}

    checksums    rmd160  7c00dcda9db1f595386a7acd580e2bdcc2382cd5 \
                 sha256  5a7eaead66971e25bef2c21d94d0760b54bda13761908545be8c0323df17da4a \
                 size    448564759

    description  GraalVM Community Edition based on OpenJDK ${major}
    long_description GraalVM is a universal virtual machine for running applications written in JavaScript, Python, \
                 Ruby, R, JVM-based languages like Java, Scala, Groovy, Kotlin, Clojure, and LLVM-based languages \
                 such as C and C++.

    homepage     https://www.graalvm.org
} elseif {${subport} eq "openjdk11-openj9"} {
    master_sites https://github.com/AdoptOpenJDK/openjdk${major}-binaries/releases/download/jdk-${version}%2B${build}.${revision}_openj9-${openj9_version}/
    # Temporary dist_subdir for stealth update: https://trac.macports.org/wiki/PortfileRecipes#stealth-updates
    dist_subdir  ${name}/${version}_${revision}

    checksums    rmd160  1915fac0403ce775419dcccaafe74de9a8432cac \
                 sha256  97dc8234b73e233316b5dfdca75af9a0d54aa23b1309b1a68fd0a5d2fa928e05 \
                 size    196981668

    distname     OpenJDK${major}U-jdk_x64_mac_openj9_${version}_${build}_openj9-${openj9_version}
    worksrcdir   jdk-${version}+${build}

    description  Open Java Development Kit ${major} (AdoptOpenJDK) with Eclipse OpenJ9 VM
    long_description AdoptOpenJDK provides prebuilt OpenJDK binaries from a fully \
                 open-source set of build scripts and infrastructure. \
                 \
                 OpenJ9 is the virtual machine from the Eclipse community. It is an enterprise-grade \
                 VM designed for low memory usage and fast start-up and is used in IBM’s JDK. It is \
                 suitable for running all workloads.
} elseif {${subport} eq "openjdk11-openj9-large-heap"} {
    master_sites https://github.com/AdoptOpenJDK/openjdk${major}-binaries/releases/download/jdk-${version}%2B${build}.${revision}_openj9-${openj9_version}/
    # Temporary dist_subdir for stealth update: https://trac.macports.org/wiki/PortfileRecipes#stealth-updates
    dist_subdir  ${name}/${version}_${revision}

    checksums    rmd160  5d0f9d8f81dec18bd5d2a57fcf2684759e87b9d3 \
                 sha256  5bfc4ad3b3568303091e3863c4c9baff279929a35326dd48fb26d8e95e8e3174 \
                 size    196984646

    distname     OpenJDK${major}U-jdk_x64_mac_openj9_macosXL_${version}_${build}_openj9-${openj9_version}
    worksrcdir   jdk-${version}+${build}

    description  Open Java Development Kit ${major} (AdoptOpenJDK) with Eclipse OpenJ9 VM for large heap sizes
    long_description AdoptOpenJDK provides prebuilt OpenJDK binaries from a fully \
                 open-source set of build scripts and infrastructure. \
                 \
                 OpenJ9 is the virtual machine from the Eclipse community. It is an enterprise-grade \
                 VM designed for low memory usage and fast start-up and is used in IBM’s JDK. It is \
                 suitable for running all workloads. \
                 \
                 This version uses non-compressed references and should be used for applications which require heaps that are over ~57 GB.
} elseif {${subport} eq "openjdk12"} {
    master_sites https://github.com/AdoptOpenJDK/openjdk${major}-binaries/releases/download/jdk-${version}%2B${build}/
    distname     OpenJDK${major}U-jdk_x64_mac_hotspot_${version}_${build}

    checksums    rmd160  298235796f231dcd79baa1eccce40b4eb4aba456 \
                 sha256  9919eee037554d40c7d2f219bbd654f2bf119e16a2f4d284d8dedaf525ee59e6 \
                 size    198392994

    worksrcdir   jdk-${version}+${build}
} elseif {${subport} eq "openjdk12-openj9"} {
    master_sites https://github.com/AdoptOpenJDK/openjdk${major}-binaries/releases/download/jdk-${version}%2B${build}_openj9-${openj9_version}/
    distname     OpenJDK${major}U-jdk_x64_mac_openj9_${version}_${build}_openj9-${openj9_version}

    checksums    rmd160  eb8b931dc23ff3adb998e9c880e027e03b11e7cf \
                 sha256  20d19ec20f65335edbf4db3861421be393d48720d5a389cd76e1c81a8aff8fee \
                 size    197951754

    worksrcdir   jdk-${version}+${build}

    description  Open Java Development Kit ${major} (AdoptOpenJDK) with Eclipse OpenJ9 VM
    long_description AdoptOpenJDK provides prebuilt OpenJDK binaries from a fully \
                 open-source set of build scripts and infrastructure. \
                 \
                 OpenJ9 is the virtual machine from the Eclipse community. It is an enterprise-grade \
                 VM designed for low memory usage and fast start-up and is used in IBM’s JDK. It is \
                 suitable for running all workloads.
} elseif {${subport} eq "openjdk12-openj9-large-heap"} {
    master_sites https://github.com/AdoptOpenJDK/openjdk${major}-binaries/releases/download/jdk-${version}%2B${build}_openj9-${openj9_version}/
    distname     OpenJDK${major}U-jdk_x64_mac_openj9_macosXL_${version}_${build}_openj9-${openj9_version}

    checksums    rmd160  01c7e4723cbee7e8a34e605a369a3986ace9d07a \
                 sha256  d7c4c75f04f75767e26ffa0083c8a365ec95e8f5ccddcc0005dbd538954064b4 \
                 size    197960269

    worksrcdir   jdk-${version}+${build}

    description  Open Java Development Kit ${major} (AdoptOpenJDK) with Eclipse OpenJ9 VM for large heap sizes
    long_description AdoptOpenJDK provides prebuilt OpenJDK binaries from a fully \
                 open-source set of build scripts and infrastructure. \
                 \
                 OpenJ9 is the virtual machine from the Eclipse community. It is an enterprise-grade \
                 VM designed for low memory usage and fast start-up and is used in IBM’s JDK. It is \
                 suitable for running all workloads. \
                 \
                 This version uses non-compressed references and should be used for applications which require heaps that are over ~57 GB.
} elseif {${subport} eq "openjdk13"} {
    master_sites https://github.com/AdoptOpenJDK/openjdk${major}-binaries/releases/download/jdk-${version}%2B${build}/
    distname     OpenJDK${major}U-jdk_x64_mac_hotspot_${version}_${build}

    checksums    rmd160  1c7fef6b601c262f245a3b40fab279abfa5fec6c \
                 sha256  9c82de98ce9bc2353bcf314d85366c9a2c572db034e10a71aa47e804e13748c1 \
                 size    198205689

    worksrcdir   jdk-${version}+${build}
} elseif {${subport} eq "openjdk13-openj9"} {
    master_sites https://github.com/AdoptOpenJDK/openjdk${major}-binaries/releases/download/jdk-${version}%2B${build}.${revision}_openj9-${openj9_version}/
    # Temporary dist_subdir for stealth update: https://trac.macports.org/wiki/PortfileRecipes#stealth-updates
    dist_subdir  ${name}/${version}_${revision}
    distname     OpenJDK${major}U-jdk_x64_mac_openj9_${version}_${build}_openj9-${openj9_version}

    checksums    rmd160  8bd31c96ae660af6af81be78dd50b2103424bfa5 \
                 sha256  ea578286d726c0cc9660625f4cd93f67fe1ca89d47584bc4d14bda71f9cb2d5d \
                 size    201722075

    worksrcdir   jdk-${version}+${build}

    description  Open Java Development Kit ${major} (AdoptOpenJDK) with Eclipse OpenJ9 VM
    long_description AdoptOpenJDK provides prebuilt OpenJDK binaries from a fully \
                 open-source set of build scripts and infrastructure. \
                 \
                 OpenJ9 is the virtual machine from the Eclipse community. It is an enterprise-grade \
                 VM designed for low memory usage and fast start-up and is used in IBM’s JDK. It is \
                 suitable for running all workloads.
} elseif {${subport} eq "openjdk13-openj9-large-heap"} {
    master_sites https://github.com/AdoptOpenJDK/openjdk${major}-binaries/releases/download/jdk-${version}%2B${build}.${revision}_openj9-${openj9_version}/
    # Temporary dist_subdir for stealth update: https://trac.macports.org/wiki/PortfileRecipes#stealth-updates
    dist_subdir  ${name}/${version}_${revision}
    distname     OpenJDK${major}U-jdk_x64_mac_openj9_macosXL_${version}_${build}_openj9-${openj9_version}

    checksums    rmd160  401a9beec2f300b0739d7757aa1bc3aacd676b44 \
                 sha256  0f8b8b11faa2d128adba469429d5fbfd524bc9948e9b16bb78ab8efb43b4018c \
                 size    201721778

    worksrcdir   jdk-${version}+${build}

    description  Open Java Development Kit ${major} (AdoptOpenJDK) with Eclipse OpenJ9 VM for large heap sizes
    long_description AdoptOpenJDK provides prebuilt OpenJDK binaries from a fully \
                 open-source set of build scripts and infrastructure. \
                 \
                 OpenJ9 is the virtual machine from the Eclipse community. It is an enterprise-grade \
                 VM designed for low memory usage and fast start-up and is used in IBM’s JDK. It is \
                 suitable for running all workloads. \
                 \
                 This version uses non-compressed references and should be used for applications which require heaps that are over ~57 GB.
}

use_configure    no

build {}

# macOS Java tools expect to find Java virtual machines under /Library/Java/JavaVirtualMachines, which is not under ${prefix}.
destroot.violate_mtree yes

set target /Library/Java/JavaVirtualMachines/${subport}
set destroot_target ${destroot}${target}

destroot {
    xinstall -m 755 -d ${destroot_target}
    copy ${worksrcpath}/Contents ${destroot_target}
}

notes "
If you have more than one JDK installed you can make JDK ${major} the default
by adding the following line to your Bash shell profile (~/.bash_profile):

    export JAVA_HOME=${target}/Contents/Home
"

if {${subport} eq "openjdk10" || [string match openjdk12* ${subport}]} {
    notes-append "
    Warning: Support for OpenJDK ${major} has reached end of life and there will be no more updates.
             Please consider migrating to a supported OpenJDK version.
             Currently OpenJDK 8, 11 and 13 are supported.
    "
}