title: Maven - Add jar-with-dependencies as a dependency
body: <p><strong>Question..</strong><br>
  I'd like to add a dependency on a Maven jar <em>packaged with it's dependencies</em>.</p>
  
  <p><strong>Details..</strong><br>
  I have a multi-module Maven project in which one of the module depends on native libraries and the like. As part of it's build, it packages up it's dependencies into a <code>jar-with-dependencies</code> as shown here:</p>
  
  <pre><code>&lt;plugin&gt;
      &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
      &lt;version&gt;2.4&lt;/version&gt;
      &lt;configuration&gt;
          &lt;descriptorRefs&gt;
              &lt;descriptorRef&gt;jar-with-dependencies&lt;/descriptorRef&gt;
          &lt;/descriptorRefs&gt;
          &lt;archive&gt;
              &lt;manifest&gt;
                  &lt;mainClass&gt;${mainClass}&lt;/mainClass&gt;
              &lt;/manifest&gt;
          &lt;/archive&gt;
      &lt;/configuration&gt;
      &lt;executions&gt;
          &lt;execution&gt;
              &lt;id&gt;make-assembly&lt;/id&gt;
              &lt;phase&gt;package&lt;/phase&gt;
              &lt;goals&gt;
                  &lt;goal&gt;single&lt;/goal&gt;
              &lt;/goals&gt;
          &lt;/execution&gt;
      &lt;/executions&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>All good, I get two jars when I build:</p>
  
  <pre><code>seaniscool-0.0.1-SNAPSHOT.jar
  seaniscool-0.0.1-SNAPSHOT-jar-with-dependencies.jar
  </code></pre>
  
  <p>However, I'd like to use this artifact in another module of the same project. If I simply add the module as a dependency, I get the jar without the native libraries included.</p>
  
  <p>I could duplicate the build configuration to include the native libraries in the 2nd module also, it's not very extensive, but would prefer not to.</p>
  
  <p>Any ideas how I can add the <code>jar-with-dependencies</code> as a dependency and thus depend on the libraries included?</p>
  
  <p><strong>Some thoughts..</strong><br>
  I know I can build a separate jar with test classes that Maven can reference:</p>
  
  <p>In 1st module:</p>
  
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
      &lt;version&gt;2.2&lt;/version&gt;
      &lt;executions&gt;
          &lt;execution&gt;
              &lt;goals&gt;
                  &lt;goal&gt;test-jar&lt;/goal&gt;
              &lt;/goals&gt;
          &lt;/execution&gt;
      &lt;/executions&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>In 2nd module:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;my.group.id&lt;/groupId&gt;
      &lt;artifactId&gt;my.artifact.id&lt;/artifactId&gt;
      &lt;version&gt;my.version&lt;/version&gt;
      &lt;type&gt;test-jar&lt;/type&gt;
      &lt;scope&gt;test&lt;/scope&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Is this concept transferrable here perhaps?</p>