version: 2
jobs:
    build:
        docker:
            - image: circleci/buildpack-deps:disco
        working_directory: ~/EasyFXML
        steps:

            - setup_remote_docker
            - checkout

            - run:
                  name: Docker build
                  command: 'docker build -t easyfxml/test .'

            - restore_cache:
                  key: m2-{{ .Branch }}-{{ checksum "pom.xml" }}
                  paths:
                      - ~/.m2/repository

            - run:
                  name: Build and Test
                  command: 'docker run -v ~/.m2:/root/.m2 easyfxml/test:latest'

            - save_cache:
                  key: m2-{{ .Branch }}-{{ checksum "pom.xml" }}
                  paths:
                      - ~/.m2/repository

            - run:
                  name: Save test results
                  command: './.circleci/copy_recursive_regex.sh ".*/target/surefire-reports/.*xml" test-results'
                  when: always
            - store_test_results:
                  path: test-results
            - run:
                  name: Save artifacts
                  command: './.circleci/copy_recursive_regex.sh ".*/target/.*jar" artifacts'
                  when: always
            - store_artifacts:
                  path: artifacts

version: 2
jobs:
    build:
        docker:
            - image: circleci/buildpack-deps:disco
        working_directory: ~/EasyFXML
        steps:

            - setup_remote_docker
            - checkout

            - run:
                  name: Docker build
                  command: 'docker build -t easyfxml/test .'

            - restore_cache:
                  key: m2-{{ .Branch }}-{{ checksum "pom.xml" }}
                  paths:
                      - ~/.m2/repository

            - run:
                  name: Build and test in Docker
                  command: 'docker run -v ~:/root easyfxml/test:latest'

            - save_cache:
                  key: m2-{{ .Branch }}-{{ checksum "pom.xml" }}
                  paths:
                      - ~/.m2/repository

            - run:
                  name: Prepare post-build
                  command: 'chmod +x ./.circleci/copy_recursive_regex.sh'
                  when: always
            - run:
                  name: Aggregate test results
                  command: './.circleci/copy_recursive_regex.sh ".*/target/surefire-reports/.*xml" test-results'
                  when: always

            - run:
                  name: Aggregate artifacts
                  command: './.circleci/copy_recursive_regex.sh ".*/target/.*jar" artifacts'
                  when: always

            - store_test_results:
                  path: test-results
            - store_artifacts:
                  path: artifacts

Test mapping whole user dir to sync all cached/saved elems
Test mapping whole user dir to sync all cached/saved elems
