language: java

sudo: required

services:
  - docker

jdk:
  - oraclejdk8

script:
  - ./gradlew check installDist &&
    (docker pull georocket/georocket || true) &&
    cp docker/.dockerignore georocket-server/build/install/.dockerignore &&
    cp docker/Dockerfile georocket-server/build/install/Dockerfile &&
    docker build -t georocket/georocket georocket-server/build/install &&
    cd georocket-server/integration-tests &&
    ./test.sh &&
    cd ../.. &&
    if [ "$TRAVIS_REPO_SLUG" == "georocket/georocket" ] && [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [[ $(./gradlew -q :georocket-server:getVersion) == *SNAPSHOT* ]]; then
    ./gradlew upload;
    fi &&
    if [ "$TRAVIS_REPO_SLUG" == "georocket/georocket" ] && ([ "$TRAVIS_BRANCH" == "master" ] || [ ! -z "$TRAVIS_TAG" ]) && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
    docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" &&
    docker push georocket/georocket;
    fi

cache:
  directories:
    - $HOME/.gradle

language: java

sudo: required

services:
  - docker

jdk:
  - oraclejdk8

script:
  - ./gradlew check installDist &&
    cp docker/.dockerignore georocket-server/build/install/.dockerignore &&
    cp docker/Dockerfile georocket-server/build/install/Dockerfile &&
    docker build -t georocket/georocket georocket-server/build/install &&
    cd georocket-server/integration-tests &&
    ./test.sh &&
    cd ../.. &&
    if [ "$TRAVIS_REPO_SLUG" == "georocket/georocket" ] && [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [[ $(./gradlew -q :georocket-server:getVersion) == *SNAPSHOT* ]]; then
    ./gradlew upload;
    fi &&
    if [ "$TRAVIS_REPO_SLUG" == "georocket/georocket" ] && ([ "$TRAVIS_BRANCH" == "master" ] || [ ! -z "$TRAVIS_TAG" ]) && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
    docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" &&
    docker push georocket/georocket;
    fi

# see also https://docs.travis-ci.com/user/languages/java/#Caching
before_cache:
  - rm -f  $HOME/.gradle/caches/modules-2/modules-2.lock
  - rm -rf $HOME/.gradle/caches/*/plugin-resolution/
cache:
  directories:
    - $HOME/.gradle/caches/
    - $HOME/.gradle/wrapper/

Speed up build a bit
Speed up build a bit

- Delete unnecessary files from Gradle cache
- Do not pull Docker image
