version: 2

jobs:
  build:
    docker:
      - image: circleci/openjdk:8-jdk-stretch-node-browsers

    environment:
      MAVEN_OPTS: -Xmx1024m

    steps:
      - checkout

      # Download and cache dependencies
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "pom.xml" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-

      - run: |
           mvn -DskipTests clean install dependency:resolve-plugins dependency:go-offline || true

      - save_cache:
          paths:
            - ~/.m2
          key: v1-dependencies-{{ checksum "pom.xml" }}

      - run:
          name: Compile and run the tests
          command: |
            mvn -DskipITs=false clean install test failsafe:integration-test

      - run:
          name: Save test results
          command: |
            mkdir -p ~/junit/
            find . -type f -regex ".*/target/failsafe-reports/.*xml" -exec cp {} ~/junit/ \;
            find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/junit/ \;
          when: always

      - store_test_results:
          path: ~/junit

workflows:
  version: 2
  build-deploy:
    jobs:
      - build


version: 2

jobs:
  build:
    docker:
      - image: circleci/openjdk:8-jdk-stretch-node-browsers

    environment:
      MAVEN_OPTS: -Xmx1024m

    steps:
      - checkout

      # Download and cache dependencies
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "pom.xml" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-

      - run:
          name: Compile and run the tests
          command: |
            mvn -DskipITs=false clean install test failsafe:integration-test

      - save_cache:
          paths:
            - ~/.m2
          key: v1-dependencies-{{ checksum "pom.xml" }}

      - run:
          name: Save test results
          command: |
            mkdir -p ~/junit/
            find . -type f -regex ".*/target/failsafe-reports/.*xml" -exec cp {} ~/junit/ \;
            find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/junit/ \;
          when: always

      - store_test_results:
          path: ~/junit

workflows:
  version: 2
  build-deploy:
    jobs:
      - build


Build once instead of twice.
Build once instead of twice.
