title: How can I use previously built jars in a multi-module maven project?
body: <p>I have <a href="https://github.com/ICIJ/datashare" rel="nofollow noreferrer">this maven multi-module project</a> : </p>
  
  <pre><code>ModuleA
    src
    pom.xml
    target
      ModuleA-with-dependencies-shaded.jar (version 4.1 of lucene relocated)
  ModuleB
    src
    pom.xml
    target
      ModuleB-with-dependencies.jar (version 7.5.0 of lucene)
  ModuleDist
    assembly
      all.xml
    pom.xml (shaded plugin for jar + assembly for Docker)
  </code></pre>
  
  <p>The dist pom plugins are configured like this : </p>
  
  <pre><code>        &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-shade-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.2.2&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;shadedClassifierName&gt;all&lt;/shadedClassifierName&gt;
                      &lt;shadedArtifactAttached&gt;true&lt;/shadedArtifactAttached&gt;
                      &lt;transformers&gt;
                          &lt;!--remove models from jar see mitie --&gt;
                          &lt;transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer"&gt;
                              &lt;resource&gt;.dat&lt;/resource&gt;
                          &lt;/transformer&gt;
                      &lt;/transformers&gt;
                      &lt;artifactSet&gt;
                      &lt;excludes&gt;
                          &lt;exclude&gt;log4j:log4j:jar:&lt;/exclude&gt;
                      &lt;/excludes&gt;
                      &lt;/artifactSet&gt;
                  &lt;/configuration&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;phase&gt;package&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;shade&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;phase&gt;package&lt;/phase&gt;
                          &lt;id&gt;make-dist&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;single&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;descriptors&gt;
                                  &lt;descriptor&gt;src/assembly/all.xml&lt;/descriptor&gt;
                              &lt;/descriptors&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
  </code></pre>
  
  <p>And the assembly all.xml : </p>
  
  <pre><code>&lt;assembly&gt;
      &lt;id&gt;all&lt;/id&gt;
      &lt;formats&gt;
          &lt;format&gt;dir&lt;/format&gt;
      &lt;/formats&gt;
      &lt;includeBaseDirectory&gt;false&lt;/includeBaseDirectory&gt;
      &lt;fileSets&gt;
          &lt;fileSet&gt;
              &lt;directory&gt;${project.basedir}/src/main/docker&lt;/directory&gt;
              &lt;outputDirectory&gt;/&lt;/outputDirectory&gt;
              &lt;includes&gt;
                  &lt;include&gt;*&lt;/include&gt;
              &lt;/includes&gt;
          &lt;/fileSet&gt;
          &lt;fileSet&gt;
              &lt;directory&gt;${project.build.directory}&lt;/directory&gt;
              &lt;outputDirectory&gt;lib&lt;/outputDirectory&gt;
              &lt;includes&gt;
                  &lt;include&gt;*.jar&lt;/include&gt;
              &lt;/includes&gt;
          &lt;/fileSet&gt;
      &lt;/fileSets&gt;
  &lt;/assembly&gt;
  </code></pre>
  
  <p>As the <code>ModuleA</code> is having a transitive dependency on <code>lucene 4.1</code> (but relocated so it won't clash with moduleB) and <code>ModuleB</code> is having a transitive dependency on <code>lucene 7.5.0</code>, I'd like to use the <strong>previously built</strong> and shaded jar of <code>ModuleA</code> in the maven shaded plugin of <code>ModuleDist</code> (because if I relocate lucene in <code>ModuleDist</code> it is relocating all lucene classes).</p>
  
  <p>How could I do that ?<br>
  or is there another way of doing this ?</p>