#
# Copyright (c) 2012-2021 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
#   Red Hat, Inc. - initial API and implementation
#

schemaVersion: 2.0.0
metadata:
  name: spring-boot-http-booster
  attributes:
    type: workspace
projects:
  - name: spring-boot-http-booster
    git:
      remotes:
        origin: https://github.com/snowdrop/spring-boot-http-booster
      checkoutFrom:
        revision: master
components:
  - name: java-support
    plugin:
      id: redhat/java8/latest
      components:
        - name: vscode-java            
          container:
            memoryLimit: 2Gi
        - name: m2
          volume:
            size: 2G
  - name: dependency-analytics
    plugin:
      id: redhat/dependency-analytics/latest
  - name: maven-tooling
    container:
      image: registry.redhat.io/codeready-workspaces/stacks-java-rhel8:2.1
      mountSources: true
      memoryLimit: 768Mi
      env:
        - name: JAVA_OPTS
          value: >-
            -XX:MaxRAMPercentage=50.0 -XX:+UseParallelGC -XX:MinHeapFreeRatio=10
            -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4
            -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true
            -Xms20m -Djava.security.egd=file:/dev/./urandom -Duser.home=/home/jboss
        - name: MAVEN_OPTS
          value: $(JAVA_OPTS)
      endpoints:
        - name: tcp-8080
          targetPort: 8080
          exposure: public
      volumeMounts:
        - name: m2
          path: /home/jboss/.m2
commands:
  - id: build 
    exec:
      component: maven
      commandLine: mvn -Duser.home=${HOME} -DskipTests clean install
      workingDir: '${PROJECTS_ROOT}/spring-boot-http-booster'
      env:
        - name: MAVEN_OPTS
          value: "-Xmx200m"
  - id: debug-remote-java-application
    vscodeLaunch:
      inlined: |
        {
          "version": "0.2.0",
          "configurations": [
            {
              "type": "java",
              "name": "Debug (Attach) - Remote",
              "request": "attach",
              "hostName": "localhost",
              "port": 8000
            }]
          }
  - id: run
    exec:
      component: maven
      commandLine: 'mvn -Duser.home=${HOME} spring-boot:run'
      workingDir: '${PROJECTS_ROOT}/spring-boot-http-booster'
      env:
        - name: MAVEN_OPTS
          value: "-Xmx200m"
  - id: debug
    exec:
      component: maven
      commandLine: >-
        mvn  -Duser.home=${HOME} spring-boot:run -Drun.jvmArguments="-Xdebug
        -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
      workingDir: '${PROJECTS_ROOT}/spring-boot-http-booster'
  - id: test
    exec:
      component: maven
      commandLine: 'mvn -Duser.home=${HOME} verify'
      workingDir: '${PROJECTS_ROOT}/spring-boot-http-booster'
      env:
        - name: MAVEN_OPTS
          value: "-Xmx200m"
  - id: dependency-analysis
    exec:
      component: maven
      workingDir: '${PROJECTS_ROOT}/spring-boot-http-booster'
      commandLine: >-
        ${HOME}/stack-analysis.sh -f
        ${PROJECTS_ROOT}/spring-boot-http-booster/pom.xml -p
        ${PROJECTS_ROOT}/spring-boot-http-booster
  - id: deploy-to-openshift 
    exec:
      component: maven
      commandLine: 'mvn fabric8:deploy -Popenshift -DskipTests'
      workingDir: '${PROJECTS_ROOT}/spring-boot-http-booster'
