<%#
 Copyright 2013-2017 the original author or authors from the JBooter project.

 This file is part of the JBooter project, see https://jbooter.github.io/
 for more information.

 Licensed 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.
-%>
os:
  - linux
services:
  - docker
language: node_js
node_js:
  - "<%= NODE_VERSION %>"
jdk:
  - oraclejdk8
sudo: false
cache:
  directories:
    - node
    - node_modules
<%_ if (buildTool === 'maven') { _%>
    - $HOME/.m2
<%_ } else if (buildTool === 'gradle') { _%>
    - $HOME/.gradle
<%_ } _%>
<%_ if (clientPackageManager === 'yarn') { _%>
    - $HOME/.yarn-cache
<%_ } _%>
env:
  global:
    - NODE_VERSION=<%= NODE_VERSION %>
    - SPRING_OUTPUT_ANSI_ENABLED=ALWAYS
    - SPRING_JPA_SHOW_SQL=false
before_install:
  - jdk_switcher use oraclejdk8
  - java -version
  - sudo /etc/init.d/mysql stop
  - sudo /etc/init.d/postgresql stop
  <%_ if (clientPackageManager === 'npm') { _%>
  - nvm install $NODE_VERSION
  - npm install -g npm
  <%_ if (clientFramework === 'angular1') { _%>
  - npm install -g bower gulp-cli
  <%_ } _%>
  - node -v
  - npm -v
    <%_ if (clientFramework === 'angular1') { _%>
  - bower -v
  - gulp -v
    <%_ } _%>
  <%_ } _%>
  <%_ if (clientPackageManager === 'yarn') { _%>
  # Repo for Yarn
  - curl -o- -L https://yarnpkg.com/install.sh | bash
  - export PATH=$HOME/.yarn/bin:$PATH
    <%_ if (clientFramework === 'angular1') { _%>
  - yarn global add bower gulp-cli
    <%_ } _%>
  <%_ } _%>
install:
  <%_ if (clientPackageManager === 'npm') { _%>
  - npm install
  <%_ } _%>
  <%_ if (clientPackageManager === 'yarn') { _%>
  - yarn install
  <%_ } _%>
script:
<%_ if (buildTool === 'maven') { _%>
  - chmod +x mvnw
  - ./mvnw clean test
<%_ } else if (buildTool === 'gradle') { _%>
  - chmod +x gradlew
  - ./gradlew clean test
<%_ } _%>
<%_ if (applicationType !== 'microservice') { _%>
    <%_ if (clientFramework === 'angular1') { _%>
  - gulp test
    <%_ } else { _%>
        <%_ if (clientPackageManager === 'yarn') { _%>
  - yarn test
        <%_ } else if (clientPackageManager === 'npm') { _%>
  - npm test
        <%_ } _%>
    <%_ } _%>
<%_ } _%>
<%_ if (buildTool === 'maven') { _%>
  <%_ if (heroku.includes('travis')) { _%>
  - ./mvnw com.heroku.sdk:heroku-maven-plugin:1.1.1:deploy -DskipTests -Pprod -Dheroku.appName=<%= herokuAppName %>
  <%_ } else { _%>
  - ./mvnw package -Pprod -DskipTests
  <%_ } _%>
<%_ } else if (buildTool === 'gradle') { _%>
  - ./gradlew bootRepackage -Pprod -x test
  <%_ if (heroku.includes('travis')) { _%>
  - ./gradlew deployHeroku
  <%_ } _%>
<%_ } _%>
notifications:
  webhooks:
    on_success: change  # options: [always|never|change] default: always
    on_failure: always  # options: [always|never|change] default: always
    on_start: false     # default: false
