<%#
 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.
-%>
machine:
    services:
        - docker
    java:
        version: oraclejdk8
    node:
        version: <%= NODE_VERSION %>
dependencies:
    cache_directories:
        - node
        - node_modules
<%_ if (buildTool === 'maven') { _%>
        - ~/.m2
<%_ } else if (buildTool === 'gradle') { _%>
        - ~/.gradle
<%_ } _%>
<%_ if (clientPackageManager === 'yarn') { _%>
        - $HOME/.yarn-cache
<%_ } _%>
    override:
        - java -version
<%_ if (clientPackageManager === 'npm') { _%>
        - npm install -g npm
    <%_ if (clientFramework === 'angular1') { _%>
        - npm install -g bower gulp
    <%_ } _%>
        - node -v
        - npm -v
    <%_ if (clientFramework === 'angular1') { _%>
        - bower -v
        - gulp -v
    <%_ } _%>
        - java -version
        - npm install
<%_ } else 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
    <%_ } _%>
        - yarn install
<%_ } _%>
test:
    override:
<%_ if (buildTool === 'maven') { _%>
        - chmod +x mvnw
        - ./mvnw clean test
<%_ } else if (buildTool === 'gradle') { _%>
        - chmod +x gradlew
        - ./gradlew clean test --no-daemon
<%_ } _%>
<%_ 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('circle')) { _%>
        - ./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 --no-daemon
    <%_ if (heroku.includes('circle')) { _%>
        - ./gradlew deployHeroku --no-daemon
    <%_ } _%>
<%_ } _%>
