image: openjdk:8-slim

variables:
  GRADLE_OPTS: "-Dorg.gradle.daemon=false"

before_script:
  - export GRADLE_USER_HOME=`pwd`/.gradle

build:
  stage: build
  script: ./gradlew clean assemble
  cache:
    key: ${CI_COMMIT_REF_SLUG}
    policy: pull-push
    paths:
      - build
      - .gradle

test:
  stage: test
  script:
    - ./gradlew --build-cache check
  cache:
    key: ${CI_COMMIT_REF_SLUG}
    policy: pull
    paths:
      - build
      - .gradle

#publish release:
#  stage: deploy
#  script: ./gradlew --build-cache publish
#  only:
#    - tags
#  cache:
#    key: ${CI_COMMIT_REF_SLUG}
#    policy: pull
#    paths:
#      - build
#      - .gradle
#
#publish snapshot:
#  stage: deploy
#  script: ./gradlew --build-cache -Psnapshot publish
#  cache:
#    key: ${CI_COMMIT_REF_SLUG}
#    policy: pull
#    paths:
#      - build
#      - .gradle