Docker COPY keep directory structure

I would like to copy specific files from directory and keep the structure of them. I have multimodule maven project and would like to benefit from docker layer caching.

I have several modules

pom.xml
A
  src/...
  pom.xml
B
  src/..
  pom.xml
C
  src/..
  pom.xml

Here, in order to cache all of the things, I need to copy all of the pom’s in my directory(keeping their directory structure) and download all the dependencies.

Is it possible to do so using Dockerfile? I have already seen other answers, however they were not enough for me. Do You have any ideas?

Here are questions which I have already checked:
Dockerfile copy keep subdirectory structure

Source: Docker Questions