language: java
dist: bionic
jdk:
- openjdk11
sudo: required

env:
  global:
  - secure: "DCpazS3nkLnter3sguXEAS2fC/1ZWNfM+XLyif9MfNFxlZdpni2vCD/jA0Rdpga8puQWHNVLyAec+RPFH/2qSmJ1c1UTV5MaLv8tPqwUX0VFA+1I6XoSv6oX4ldHTBWHEWqQHkRFOLoil0h0edc0tTOWQwXF8U+DLAB+HkRb4gw="

services:
- xvfb

addons:
  sonarcloud:
    organization: "iluwatar"
    token:
      secure: "FpHwMYPMkdWU6CeIB7+O3qIeIM4vJMp47UjkKK53f0w0s6tPZofZZkab+gcL2TqKSil7sFVB/AQXU1cUubflRszwcLbNsc8H2yFehD79o0o0Mqd1Dd5ip/q0KQbHkkln+InFlVLfvrLB4Xd4mlQVxbGhqpULBhXjKzFzQlRFcuU="
script:
  # Because of Travis security restrictions, SonarCloud analysis cannot be run on pull requests originated from forks
  # See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
  - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then mvn clean verify; fi'
  - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then mvn clean verify sonar:sonar -Dsonar.projectKey=iluwatar_java-design-patterns -Dsonar.host.url=https://sonarcloud.io; fi'

after_success:
- bash update-website.sh

notifications:
  email:
    - iluwatar@gmail.com
  webhooks:
    urls:
      - https://webhooks.gitter.im/e/3319623945358a093a6f
    on_success: change  # options: [always|never|change] default: always
    on_failure: always  # options: [always|never|change] default: always
    on_start: never     # options: [always|never|change] default: always
