language: java

jdk:
  - oraclejdk9
  - openjdk8

matrix:
  include:
    - jdk: oraclejdk8
      addons:
        sonarcloud:
          organization: "i2p"
    - jdk: openjdk7
      sudo: required
      before_install: # Work around missing crypto in openjdk7
        - sudo wget "https://bouncycastle.org/download/bcprov-ext-jdk15on-158.jar" -O "${JAVA_HOME}/jre/lib/ext/bcprov-ext-jdk15on-158.jar"
        - sudo perl -pi.bak -e 's/^(security\.provider\.)([0-9]+)/$1.($2+1)/ge' /etc/java-7-openjdk/security/java.security
        - echo "security.provider.1=org.bouncycastle.jce.provider.BouncyCastleProvider" | sudo tee -a /etc/java-7-openjdk/security/java.security

before_install:
 - |
    if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ]; then
      sed -i "1iplugins {\n    id 'org.sonarqube' version '2.6.1'\n}\n" build.gradle
    fi

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/
    - $HOME/.sonar/cache/
    - .gradle

script:
  - |
    if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ]; then
      ./gradlew sonarqube codeCoverageReport
    else
      ./gradlew check codeCoverageReport
    fi

after_success:
  - bash <(curl -s https://codecov.io/bash)

notifications:
  irc:
    channels:
      - "chat.freenode.net#i2p-dev"
    on_success: change
    on_failure: always
