# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem      1.0
PortGroup       java 1.0
PortGroup       app 1.0

name            jmeter
version         5.6.3
revision        0
categories      devel benchmarks java net
license         Apache-2
supported_archs i386 x86_64
maintainers     {judaew @judaew} openmaintainer

java.version    1.8+
java.fallback   openjdk21

description     Apache JMeter - Load testing tool
long_description \
    Apache JMeter is a Java application designed to load test functional \
    behavior and measure performance. It was originally  designed  for  \
    testing  web applications  but  has  since expanded to other test functions.
homepage        https://jmeter.apache.org

distname        apache-${name}-${version}
extract.suffix  .tgz
master_sites    https://archive.apache.org/dist/jmeter/binaries/

checksums       rmd160  c8777abd190d8c77e676c2393ea70c21c02db2a4 \
                sha256  f68efc17fe060f698c48a6abe2599a933927486bda2924dbe14c74895318ddde \
                size    87414762

use_configure   no

build {}

app.name                JMeter
app.icon                ${worksrcpath}/docs/images/favicon.png
app.executable          ${worksrcpath}/jmeter_launcher.sh
app.use_launch_script   yes

variant launcher description "Generate application launcher bundle" {}
default_variants +launcher
if {![variant_isset launcher]} {
    app.create  no
}

pre-destroot {
    # Remove extraneous bat and cmd files
    delete {*}[glob -directory ${worksrcpath}/bin *.bat]
    delete {*}[glob -directory ${worksrcpath}/bin *.cmd]

    if {[variant_isset launcher]} {
        copy ${filespath}/jmeter_launcher.sh ${worksrcpath}
        reinplace "s|@@PREFIX@@|${prefix}|g" \
            ${worksrcpath}/jmeter_launcher.sh
    }
}

destroot {
    # Copy over the needed elements of our directory tree
    xinstall -m 755 -d ${destroot}${prefix}/share/${name}
    copy ${worksrcpath}/bin \
         ${worksrcpath}/lib \
         ${worksrcpath}/extras \
         ${destroot}${prefix}/share/${name}

    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 640 -W ${worksrcpath} LICENSE NOTICE README.md \
         ${destroot}${prefix}/share/doc/${name}
    copy ${worksrcpath}/docs ${destroot}${prefix}/share/doc/${name}
    copy ${worksrcpath}/licenses ${destroot}${prefix}/share/doc/${name}

    # Symlink jmeter and jmeter-server into the bin directory
    ln -s ${prefix}/share/$name/bin/jmeter ${destroot}${prefix}/bin
    ln -s ${prefix}/share/$name/bin/jmeter-server ${destroot}${prefix}/bin
}

notes "
Some jars are not included with JMeter. If required, these should\
be downloaded and placed in the lib directory: ${prefix}/share/${name}/lib
- JDBC - available from the database supplier
- JMS - available from the JMS provider
- Bouncy Castle - only needed for SMIME Assertion
"
