language: java

# skip default "install" command
install: true

# We can clean the caches via web at https://travis-ci.org/apache/jmeter/caches
before_cache:
  - F=CleanupGradleCache sh -x -c 'curl -O https://raw.githubusercontent.com/vlsi/cleanup-gradle-cache/v1.x/$F.java && javac -J-Xmx128m $F.java && java -Xmx128m $F'
  - rm -rf $HOME/.m2/repository/org/apache/jmeter

cache:
  directories:
    - $HOME/.gradle/caches/
    - $HOME/.gradle/wrapper/
    - $HOME/.m2/repository

env:
  global:
    - SKIP_TAR="-x distTar -x distTarSource"
    - ORG_GRADLE_PROJECT_checksumFailOn=build_finish
    - ORG_GRADLE_PROJECT_checksumPrint=true

matrix:
  allow_failures:
    # j-m-p does not seem to download all the dependencies: https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/issues/187
    - name: jmeter-maven-plugin tests
    - name: jmeter-maven-plugin tests on s390x
    - name: Tests with OpenJDK 11 on s390x
  include:
    - name: Tests with OpenJDK 8 + code coverage
      jdk: openjdk8
      script:
        - xvfb-run ./gradlew build jacocoReport $SKIP_TAR
      after_success:
        - bash <(curl -s https://codecov.io/bash)
    - name: Tests with OpenJDK 11
      jdk: openjdk11
      addons:
        apt:
          packages:
            - language-pack-fr
      env:
        - TZ=Pacific/Chatham # flips between +12:45 and +13:45
        - LANG=fr_FR.UTF-8
        - LC_ALL=fr_FR.UTF-8
      script:
        # This job verifies headless mode to ensure Apache JMeter is workable in headless as well
        # Spotless and Checkstyle are skipped here to save some time. They are verified anyway in Java 8 and Java 13 builds, so skipping them for Java 11 does not harm
        - ./gradlew build -Djava.awt.headless=true -Duser.language=fr -Duser.country=FR -PskipCheckstyle -PskipSpotless $SKIP_TAR
    - name: Tests with OpenJDK 11 on s390x
      os: linux
      arch: s390x
      dist: bionic
      jdk: openjdk11
      addons:
        apt:
          packages:
            - language-pack-fr
      script:
        - sudo apt-get install -y openjdk-11-jdk
        - export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-s390x/
        - export PATH=$JAVA_HOME/bin:$PATH
        - ./gradlew build -Djava.awt.headless=true -PskipCheckstyle -PskipSpotless $SKIP_TAR
    # Java 12 is not here because it has been superceeded by Java 13
    # Tests with Java 12 do not surface much new, so Java 11 (LTS) and Java 13 (non-LTS) are enough for "post Java 9" testing
    - name: Tests with OpenJDK 14
      jdk: openjdk14
      addons:
        apt:
          packages:
            - language-pack-fr
      env:
        - TZ=America/New_York # flips between −05:00 and −04:00
        - LANG=fr_FR.UTF-8
        - LC_ALL=fr_FR.UTF-8
      script:
        # Spotless, Checkstyle, and JaCoCo are verified here to ensure they all work with the latest supported Java
        - xvfb-run ./gradlew build jacocoReport -Duser.language=fr -Duser.country=FR $SKIP_TAR
    - name: jmeter-maven-plugin tests
      jdk: openjdk8
      script:
        - ./gradlew -PskipJavadoc publishToMavenLocal -Pjmeter.version=42.0 -PchecksumIgnore
        - cd ..
        - git clone --depth 100 https://github.com/jmeter-maven-plugin/jmeter-maven-plugin.git
        - cd jmeter-maven-plugin
        - mvn verify -Djmeter.version=42.0-SNAPSHOT
    - name: jmeter-maven-plugin tests on s390x
      os: linux
      arch: s390x
      jdk: openjdk11
      script:
        - wget http://www.eu.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
        - tar -xvzf apache-maven-3.6.3-bin.tar.gz
        - export PATH=`pwd`/apache-maven-3.6.3/bin/:$PATH
        - ./gradlew -PskipJavadoc publishToMavenLocal -Pjmeter.version=42.0 -PchecksumIgnore
        - cd ..
        - git clone --depth 100 https://github.com/jmeter-maven-plugin/jmeter-maven-plugin.git
        - cd jmeter-maven-plugin
        - mvn verify -Djmeter.version=42.0-SNAPSHOT
