Maven multi module project (reactor): Install goal does not see dependencies that have been built a while ago

Hello,

I’ve just started using CircleCi and spent about 3 hours trying solve this problem.

Context:
I have one maven project with several modules inside. There is core module and other modules depend on it.

Problem:
When running man clean install on parent project only the core module is built successfully. Maven cannot resolve dependency to built core module even though I can see jar in cached .m2 directory:

[ERROR] Failed to execute goal on project webapp: Could not resolve dependencies for project org.automate:webapp:jar:1.1.0: Could not find artifact org.automate:core:jar:1.0.0 in central (https://repo.maven.apache.org/maven2) -> [Help 1]

How should I configure it in config file to allow maven see a dependency that has been built?
Here is my config file

version: 2
jobs:
build:

working_directory: ~/tmp
docker:
  - image: circleci/openjdk:8-jdk-browsers

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 clean install

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

I had the same problem with a multi module project with spring. I found the solution using this config.yml

version: 2
jobs:
build:
working_directory: ~/my-multi-module-mvn-prj

docker:
  - image: circleci/openjdk:8-jdk-stretch

steps:
  - checkout

  - run:
      name: Generate cumulative pom.xml checksum
      command: |
        find . -type f -name "pom.xml" -exec sh -c "sha256sum {} >> ~/pom-checksum.tmp" \;
        sort -o ~/pom-checksum ~/pom-checksum.tmp
      when: always

  - restore_cache:
      keys:
        - my-multi-module-mvn-prj-{{ checksum "~/pom-checksum" }}
        - my-multi-module-mvn-prj-

  - run: mvn de.qaware.maven:go-offline-maven-plugin:resolve-dependencies

  - save_cache:
      paths:
        - ~/.m2
      key: my-multi-module-mvn-prj-{{ checksum "~/pom-checksum" }}

  - run: mvn package

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

  - store_test_results:
      path: ~/test-results

  - store_artifacts:
      path: my-service/target/my-service.jar

source: https://gist.github.com/dartov/149a1680a50c636b418119ba653a6ebb