dist: trusty

language: java

script: ./mvnw verify javadoc:javadoc site:site

install:
- ./mvnw --version

stages:
  - test
  - name: deploy
    if: (branch = main) AND (NOT type IN (pull_request))

jobs:
  include:
    - name: Java 6
      env: JDK=openjdk6
      addons:
        apt:
          packages:
            - openjdk-6-jdk
      install:
        # Download dependencies with JDK 8 because Mave Central supports
        # TLS 1.2 only but OpenJDK 6 does not.
        - export ORIGINAL_JAVA_HOME=$JAVA_HOME
        - jdk_switcher use oraclejdk8
        - ./mvnw test -DskipTests
        # Delete all files created with JDK 8
        - ./mvnw clean
        # Restore desired JDK
        - export JAVA_HOME=$ORIGINAL_JAVA_HOME
        - jdk_switcher use openjdk6
        - ./mvnw --version
    - name: Java 7
      jdk: openjdk7
    - name: Java 8
      jdk: oraclejdk8
    - name: Java 9
      jdk: oraclejdk9
    - name: Java 10
      jdk: openjdk10
    - name: Java 11
      jdk: openjdk11
    - stage: deploy
      name: "Publish snapshot artifacts"
      addons:
        apt:
          packages:
            - openjdk-6-jdk
      install:
        # Download dependencies with JDK 8 because Mave Central supports
        # TLS 1.2 only but OpenJDK 6 does not.
        - export ORIGINAL_JAVA_HOME=$JAVA_HOME
        - jdk_switcher use oraclejdk8
        - ./mvnw test -DskipTests
        # Delete all files created with JDK 8
        - ./mvnw clean
        # Restore desired JDK
        - export JAVA_HOME=$ORIGINAL_JAVA_HOME
        - jdk_switcher use openjdk6
        - ./mvnw --version
      env:
        - JDK=openjdk6
        # OSSRH_USERNAME
        - secure: griGZYDtqDMRUaYex/uAnpkWIQ/yodM6IOn4G8izWKpyGLeCxyXBG0FDcVo81xRq/9mMevj2idyW/xNP/HAQ45G4pyJUk/vTSMkNslzVjr7OBEtQQCN8XahSaOO0l0CJ5lzA6LdwWg7uDaf9znqZ0slt81u0S1NJmUZyYeUEim0=
        # OSSRH_PASSWORD
        - secure: EM7Z2M09HvLJXYJaeD/YmeF5A6tqavG2tBBeDcFZ7C6k0AI/wApe882pEMMoUG06xufKfSlt7WFJxoyU3M+fPOpeK5qZpJQxsHWnNJwbcbKzqMpM9mDsgIL9rtAvm9MuIIbIY2spiT0Cx3sHdh5qofaJHPL/u8Or5L9tE8FV1ew=
      script: ./mvnw deploy --batch-mode --activate-profiles generate-docs --settings .travis.settings.xml
