language: java

sudo: false

env:
  global:
    - "AWS_ACCESS_KEY_ID=AKIAJQUIQIL3XTBHT3DA"
    # our AWS_SECRET_ACCESS_KEY follows
    - secure: "C5Y0miWN35KMpWNT/r3n31J/JjUJA6a9I/w5DUkm5xFLv1oStOvNL9KykRQIL4+9yW7hYUcGOI0iP9ZjtbxRouP5//PCjhlgzIGJ3WImVZq4fLNl3sq3DYtgZJT5rUeXn8r8cKE3/sloEbcbz7dFNXmbSACuaZ0/T3IZpgP/Yrs="

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

cache:
  apt: true
  directories:
  - lib/
  - $HOME/.m2
  - $HOME/.gradle/caches/
  - $HOME/.gradle/wrapper/

before_install: echo -e "org.gradle.parallel = true\norg.gradle.jvmargs=-Xms256m -Xmx1024m\norg.gradle.configureondemand=true\ntasks.withType(Test) {\n maxParallelForks = Runtime.runtime.availableProcessors()\n}" > gradle.properties
install: "./gradlew jar"

jdk:
  - openjdk8
  - openjdk11
  - openjdk15

before_deploy:
  - "./gradlew javadoc ; true"
  - "pip install --user awscli"
  - "./gradlew copyRuntimeLib"
deploy:
  - provider: script
    script: ~/.local/bin/aws s3 sync --region=us-east-1 --cache-control "public, max-age=86400" --content-encoding utf-8 --delete build/docs/javadoc/ s3://website-javadoc.freenetproject.org
    skip_cleanup: true
    on:
      branch: next
      jdk: openjdk8
  - provider: script
    script: ./gradlew -x test publish
    skip_cleanup: true
    on:
      tags: true
      jdk: openjdk8
  - provider: releases
    skip_cleanup: true
    api_key:
      - secure: CDYRFrmkAOdn4QJVww6/pziDVdZ67fvRsLOKbilao/oRdP0uvsYS+OfX+Spu/Y0qCY0xSehvqgUoD8KoFqWuhos3iF4N515S5WNuiqOao7Ac2vBCt0ZMJy7MktyE5mYOD1Paf891n6Z+eILWGI54GGEau3JPes0G9jdMphW4ma8=
    prerelease: true
    file: build/output/*jar
    file_glob: true
    on:
      tags: true
      jdk: openjdk8
