apiVersion: 1.0.0
metadata:
  name: java-fuse-diwu
projects:
  - name: java-fuse
    source:
      location: 'https://github.com/apupier/fuse-rest-http-booster.git'
      type: git
      branch: CRW-2591-fixExample
components:
  - id: redhat/java11/latest
    type: chePlugin
  - id: redhat/vscode-apache-camel/latest
    type: chePlugin
  - id: redhat/dependency-analytics/latest
    type: chePlugin
  - mountSources: true
    endpoints:
      - name: '8080'
        port: 8080
      - attributes:
          public: 'false'
        name: debug
        port: 5005
    memoryLimit: 768Mi
    type: dockerimage
    volumes:
      - name: m2
        containerPath: /home/jboss/.m2
    alias: maven
    image: 'quay.io/crw/udi-rhel8:2.16'
    env:
      - 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: JAVA_OPTS
      - value: $(JAVA_OPTS)
        name: MAVEN_OPTS
commands:
  - name: 1. Build
    actions:
      - workdir: '${CHE_PROJECTS_ROOT}/java-fuse'
        type: exec
        command: MAVEN_OPTS='-Xmx200m' && mvn clean package
        component: maven
  - name: 2. Run
    actions:
      - workdir: '${CHE_PROJECTS_ROOT}/java-fuse'
        type: exec
        command: 'mvn spring-boot:run'
        component: maven
  - name: 3. Run in debug mode
    actions:
      - workdir: '${CHE_PROJECTS_ROOT}/java-fuse'
        type: exec
        command: 'mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"'
        component: maven
  - name: 4. Log into deployment cluster
    actions:
      - workdir: '${CHE_PROJECTS_ROOT}/java-fuse'
        type: exec
        command: |
          echo
          echo "Before you can deploy this application to an openshift cluster,"
          echo "you must run 'oc login ...' in the maven terminal."
          echo
        component: maven
  - name: 5. Deploy to OpenShift
    actions:
      - workdir: '${CHE_PROJECTS_ROOT}/java-fuse'
        type: exec
        command: 'mvn oc:deploy -Popenshift -DskipTests'
        component: maven
  - name: Debug remote java application
    actions:
      - referenceContent: |
          {
          "version": "0.2.0",
          "configurations": [
            {
              "type": "java",
              "name": "Debug (Attach) - Remote",
              "request": "attach",
              "hostName": "localhost",
              "port": 5005
            }]
          }
        type: vscode-launch
