language: java
sudo: false

jdk:
  - openjdk8
  - openjdk9
  - openjdk11
  - openjdk13

before_cache:
  - rm -f  $HOME/.gradle/caches/modules-2/modules-2.lock
  - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
  directories:
    - $HOME/.gradle/caches/
    - $HOME/.gradle/wrapper/

before_install:
  - ./gradlew --version
  - java -version

stages:
  - name: test
  - name: snapshot
    if: branch = master AND type IN (push) AND tag IS blank
  - name: release
    if: type IN (push) AND tag IS present

jobs:
  include:
    # publish snapshot to oss.jfrog.org
    - stage: snapshot
      jdk: openjdk11
      script: ./gradlew artifactoryPublish

    # release a new stable version to bintray
    - stage: release
      jdk: openjdk11
      script: ./gradlew bintrayUpload -Drelease=true
