sudo: false
language: android
jdk:
  - oraclejdk8
branches:
  only:
  - master
install:
# Let's use the new command 'sdkmanager' to install Android SDK components
- yes | sdkmanager --verbose "build-tools;26.0.3"
- yes | sdkmanager --verbose "platform-tools"
- yes | sdkmanager --verbose "tools"
- yes | sdkmanager --verbose "platforms;android-26"
- yes | sdkmanager --verbose "system-images;android-24;default;armeabi-v7a"

# Check tools and dependencies installed
- yes | sdkmanager --list

# After Travis updated image with Android base environment, building via ant is not possible anymore.
# Port library tests to new-style with JUnit 4 and gradle build.
- rm pom.xml

# On the other hand, Travis still uses 'android' command behind the 'components' section update. 
# That command is obsolete and cannot update Android SDK Tools after 25.2.5.
# Let's solve it here with the new command 'sdkmanager'
- yes | sdkmanager --verbose tools
script:
- ./gradlew clean build
env:
  global:
  # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
  #   via the "travis encrypt" command using the project repo's public key
  - secure: epTZ0zZGDbHL3o6vSC9uNkZsi5j5SA6O/tvQBH7QW/dluuzIJxIjfhNbZHDyBReYDleirLzUFQpdWAUdvulCMLs/qZdIzFGlYXZSpxEnvPYMGQcilwADdJcxLw8L+3+ET5hSexxhjrTGw427IljkqGUpqQTxaLwFdFu98lDWSbc=
  matrix:
  - ANDROID_TARGET=android-26 ANDROID_ABI=armeabi-v7a
addons:
  coverity_scan:
    project:
      name: owncloud/android-library
      description: Build submitted via Travis CI
    notification_email: lukas@owncloud.com
    build_command_prepend: gradle clean
    build_command: gradle build
    branch_pattern: coverity_scan
