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:
                  keys:
                      - m2-{{ .Branch }}-{{ checksum "pom.xml" }}
                      - m2-{{ .Branch }}-{{ checksum "pom.xml" }}
                      - m2-{{ checksum "pom.xml" }}
                  paths:
                      - ~/.m2/repository
            - run: mvn dependency:go-offline
            - save_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'

            - store_test_results:
                  path: "**/target/surefire-reports"
            - store_artifacts:
                  path: "**/target/*.jar"

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:
                  keys:
                      - m2-{{ .Branch }}-{{ checksum "pom.xml" }}
                      - m2-{{ .Branch }}-{{ checksum "pom.xml" }}
                      - m2-{{ 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

            - store_test_results:
                  path: "**/target/surefire-reports"
            - store_artifacts:
                  path: "**/target/*.jar"

Use mapping only for cache management
Use mapping only for cache management
