distributable:
  url: https://dlcdn.apache.org/jmeter/binaries/apache-jmeter-{{version.raw}}.tgz
  strip-components: 1
versions:
  url: https://dlcdn.apache.org/jmeter/binaries/
  match: /apache-jmeter-\d+\.\d+(\.\d+)*\.tgz/
  strip:
    - /^apache-jmeter-/
    - /\.tgz/
warnings:
  - vendored
dependencies:
  openjdk.org: '*'
runtime:
  env:
    JAVA_HOME: '{{deps.openjdk.org.prefix}}'
build:
  dependencies:
    gnu.org/wget: '*'
  script:
    - rm -r bin/*.bat bin/*.cmd
    - mkdir -p {{prefix}}
    - mv bin docs extras lib {{prefix}}/
    - run: |
        wget -O $PLUGINS_MANAGER_FILE $PLUGINS_MANAGER_URL
        mv $PLUGINS_MANAGER_FILE {{prefix}}/lib/ext/
      working-directory: plugins-manager
  env:
    PLUGINS_MANAGER_URL: https://search.maven.org/remotecontent?filepath=kg/apc/jmeter-plugins-manager/1.9/jmeter-plugins-manager-1.9.jar
    PLUGINS_MANAGER_FILE: jmeter-plugins-manager-1.9.jar
provides:
  - bin/jmeter
  - bin/jmeter-server
  - bin/mirror-server
test:
  # Caused by: java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: /__w/pantry/pantry/testbeds/apache.org???jmeter-5.6.3
  working-directory: $(mktemp -d)
  script:
    - cat $FIXTURE > test.jmx
    - jmeter -n -t test.jmx | grep 'end of run'
    - jmeter --version | grep {{version}}
  fixture: |
    <?xml version="1.0" encoding="UTF-8"?>
    <jmeterTestPlan version="1.2" properties="5.0" jmeter="5.5">
        <hashTree>
            <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
            </TestPlan>
            <hashTree>
                <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
                    <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
                    <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
                        <boolProp name="LoopController.continue_forever">false</boolProp>
                        <stringProp name="LoopController.loops">1</stringProp>
                    </elementProp>
                    <stringProp name="ThreadGroup.num_threads">1</stringProp>
                </ThreadGroup>
                <hashTree>
                    <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="Debug Sampler" enabled="true">
                    </DebugSampler>
                    <hashTree>
                        <JSR223PostProcessor guiclass="TestBeanGUI" testclass="JSR223PostProcessor" testname="JSR223 PostProcessor" enabled="true">
                            <stringProp name="cacheKey">true</stringProp>
                            <stringProp name="script">import java.util.Random
          Random rand = new Random();
          // This will break unless Groovy accepts the current version of the JDK
          int rand_int1 = rand.nextInt(1000);
                            </stringProp>
                            <stringProp name="scriptLanguage">groovy</stringProp>
                        </JSR223PostProcessor>
                        <hashTree/>
                    </hashTree>
                </hashTree>
            </hashTree>
        </hashTree>
    </jmeterTestPlan>
