language: java
cache:
  directories: $HOME/.gradle
jdk:
  - oraclejdk8
  - oraclejdk7
  - openjdk7
script: ./gradlew build javadoc

# Release the plugin via GitHub releases when pushing a tag
deploy:
  provider: releases
  api_key: "${GH_TOKEN}"
  file: "build/libs/josm-mapillary-plugin.jar"
  skip_cleanup: true
  on:
    tags: true

#Deploy to GitHub pages
after_success: |
  if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ]; then
    git config --global user.email "deploy@travis"
    git config --global user.name "Travis CI"
    git remote add deploy "https://floscher:${GH_TOKEN}@github.com/floscher/josm-mapillary-plugin.git"
    git fetch --depth=1 origin gh-pages:gh-pages
    git checkout gh-pages
    git rm -r reports/ docs/
    mkdir -p reports/ docs/
    cp -R build/docs/javadoc/ docs/javadoc/
    cp -R build/reports/tests/ reports/junit/
    cp -R build/reports/jacoco/ reports/jacoco/
    cp -R build/reports/findbugs/ reports/findbugs/
    git stage docs/ reports/
    masterCommit=`git rev-parse master`
    git commit -m "Publish developer resources to GitHub pages

  These resources are generated by Travis CI for commit $masterCommit using Gradle."
    git push deploy gh-pages
  fi
env:
  global:
    secure: P97HMtlV6bHf1uiNZ3ka4wBITzt4IU0DB5/oqp0SInAIEQWZF+Setnp2dByJQMmIm0I/Mg2Uj3V3MZdE4sr43OU3PcAUy1RwUXiqds4ubrkbF3nTs8I4ynsmFTsclCqFsoYxyTtNYBctzw8Fc6Yuyb8BvkJvauFoSiqUSzTt+jjsY/AgZusyc4+ZitSU8xd3M7FX8pFkPuktDKE5Eo801XeRCXN4L6drMyZNrQh6sZLKuXXq32MxSsFHDlULCYeVNuG7ehtR3P5Wuds+BRaxW8VwFLkbNPe/jQVYg7kjF4afwM2AWsx2T8Vu60YV1GsW2o2csuznj1EmDjl83qpUV+NS66rkLXHPMXyfVMXpVZ9JmmM7rCVwzPtTxJyZXhaOwu8QyCKinQFkRAvwA5MEuoxBltUBubdCcAFdN6518WpQK5Me1/jRKahZbWtat7Zt+Yh4/wfaxAJhWG14fcDAX8CODdhcPhBvDAiRWPRe2xjtshuKfoRZtRrLxqV48ze6JyMuLRlKbaG5MfBpjnlX+IQPXb8Lv+SZ2k/REoovo/tIHx2eGOpmVFqR0pjVdp8/rQfya9vEaRH6axIW4p871D5c/58K6chkEhGb/ijn9GPtiWTAmxWrQO+nOrTiN68BzUtez111caKtRYlM+XYRjl8Tspor13D9+FHP+Qpkpx0=
