language: java
sudo: false
matrix:
  fast_finish: true
  include:
    - jdk: openjdk7
    - jdk: oraclejdk8
      # Java 9 needs to be manually installed/upgraded
      # see: https://github.com/travis-ci/travis-ci/issues/2968#issuecomment-149164058
    - jdk: oraclejdk9
      env: JVM=latest
      sudo: required
      dist: trusty
      group: edge
  allow_failures:
    - jdk: oraclejdk9

env:
  global:
    - BASEURL=https://www-eu.apache.org/dist/maven/maven-3/VERSION/binaries/apache-maven-VERSION-bin.zip
    - FILE=apache-maven-VERSION-bin.zip
    - DIR=apache-maven-VERSION
    - VERSION=3.3.9
#    - secure: "j6a61/qnfFcSjx5XxmxO2hqBOwtVx5HWrD1+4Atl7WG/pRKz9+jSga1Y7oDAFb2SIl8S65kDmPQB/vC8aHxUDj/Wizjxnxn1FhPqoe9yO6Ztft+984FKFyvj7s6tsBJKcehGec+chTOwZQpH4oI4rU6IlepDHnGLHiOd0Iviryg="
#    - secure: "GiFr+v2lTQk/sTQB7CYjju1/mupS8LSJupmizLqY454utiZkabDMBOZQnF9ukpy7WhveB9hKQyEKf9iP2w7HSYEjgvogT26vZ5f2MeLnR4SWvqEtf/WBvvh+W+k/rb2f6YgitkB4Jlxn2izemBEDuKplGJphzGW41lf8XZ2IxVI="

before_install:
   # update maven
   - if [ "$TRAVIS_OS_NAME" == "linux" ]; then
         wget --no-check-certificate $(echo -n $BASEURL | sed -e 's#VERSION#'$VERSION'#g');
         unzip -qq $(echo -n $FILE | sed -e 's#VERSION#'$VERSION'#');
         export M2_HOME=$PWD/$(echo -n $DIR | sed -e 's#VERSION#'$VERSION'#');
         export PATH=$M2_HOME/bin:$PATH;
     fi
   # update java 9
   - if [ "$TRAVIS_OS_NAME" == "linux" ] && [ "$JVM" == "latest" ]; then
         sudo apt-get update -qq;
         sudo /bin/echo -e oracle-java9-installer shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections;
         sudo apt-get -o Dpkg::Options::="--force-confnew" install -y oracle-java9-installer oracle-java9-set-default oracle-java9-unlimited-jce-policy;
         sudo update-java-alternatives -s java-9-oracle;
     fi
#   - if [ "$TRAVIS_JDK_VERSION" == oraclejdk9 ]; then
#         sudo rm /etc/mavenrc;
#     fi

install: true

script:
  - mvn clean test verify -B
  - mvn clean package

notifications:
  email:
    - $EMAIL
    
cache:
  directories:
    - $HOME/.m2

deploy:
  provider: script
  script: "mvn deploy --settings .travis.settings.xml -DskipTests=true -B -P selected-build"
  skip_cleanup: true
  on:
    branch: master

