# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# use https://github.com/DanySK/Gravis-CI for Maven Builds on Windows

# Java is not yet supported on Windows, so the build would block.
# You do not need any setup from Travis, use a plain bash build
language: bash
# Enable them all, if you need them.
os:
  - linux
#  - osx
  - windows
git:
  symlinks: true
env:
  global:
    # This is a convenience variable for shortening download commands
    - GRAVIS="https://raw.githubusercontent.com/DanySK/Gravis-CI/master/"
    - MAVEN_VERSION="3.6.3"
    # If you use Windows, you may want to disable Windows Defender. It slows down the builds
    # dramatically, also during cache setup. From a Tanzinul Islam's idea: http://bit.ly/348VPYS,
    # This work around disables it before caching
    - NO_WIN_DEFENDER=$(curl "${GRAVIS}.disable-windows-defender.sh" --output .no-defender.sh && source .no-defender.sh)
  matrix:
    # List any JDK you want to build your software with.
    # You can see the list of supported environments by installing Jabba and using ls-remote:
    # https://github.com/shyiko/jabba#usage
    # Partial versions are allowed. They are dynamically resoved by launching jabba ls-remote,
    # filtering for the provided JDK string, then picking the *first* match. This is useful if
    # the intent is to target the latest release of some Java major release, or if the latest
    # available build differs among platforms.
    - JDK="adopt@1.8"
    - JDK="adopt@1.11"
    - JDK="adopt@1.16"
jobs:
  include:
  - os: linux
    env:
       - JDK="adopt@1.11"
       - LANG="de_DE.UTF-8"
       - LC_ALL="de_DE.UTF-8"
       - SONARQUBE_EXECUTION=true
before_install:
  # Download the script
  - curl "${GRAVIS}.install-jdk-travis.sh" --output ~/.install-jdk-travis.sh
  # Download, install, configue the JDK, and export the configuration to the current shell
  - source ~/.install-jdk-travis.sh
  - curl "${GRAVIS}.install-maven.sh" --output ~/.install-maven.sh
  # Download, install, configue the JDK, and export the configuration to the current shell
  - source ~/.install-maven.sh
addons:
  sonarcloud:
    organization: "apache"
    token:
      secure: "EMpJMtN+fqjuyy69BByyUc08QGzgYCA8s40HDLofCExA/7i0o8tDMwLm2nVBUO5RNrvK8YDxdNI4P6zRAytws/KIw8WPJG4ycN3OFhaqccZit0zWzHO+JAD3r7rSc7dRTmC3KzeMjEHJbsbKQywLVUuaSy6vf8x5GJT2KG73hIU=" # encrypted value of your token
# This is your main script
script:
  - | 
    if [ "$SONARQUBE_EXECUTION" == "true" ]; then 
      mvn clean verify sonar:sonar -B -Pjacoco-report -Dsonar.projectKey=apache_jackrabbit-filevault -Dlogback.configurationFile=vault-core/src/test/resources/logback-only-errors.xml
    else
      mvn clean verify -B
    fi
# If you use Gradle, cleanup the build cache from lock/temporary files
before_cache:
  #- curl "${GRAVIS}.clean_gradle_cache.sh" --output ~/.clean_gradle_cache.sh
  #- bash ~/.clean_gradle_cache.sh
cache:
  directories:
    # This avoids re-downloading the JDK every time, but Travis recommends not to do it
    # - $HOME/.jabba/
    # Cache Maven repo
    - $HOME/.m2