title: How to create a single library jar from maven project with multiple submodules?
body: <p>I have a quite large java maven project with over 200 modules, it is OK as is. I am trying to merge all of those modules to single jar. </p>
  
  <p>In some cases it would be very handy to declare just one new maven dependency eg. my-library-5.2.4-SNAPSHOT-bundle.jar or something similar in new projects.</p>
  
  <p>I have tried to use maven assembly-plugin. I can create new jar file, jar contains all the module jars and it goes properly to local .m2 -folder if I install it. Jar can be declared as dependency in other projects.</p>
  
  <p>But the problem is that I can't import any of those modules inside the library in my java classes. Importing won't recognise those. </p>
  
  <p>I have added this build section to my root pom.xml:</p>
  
  <pre><code>&lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;make-bundle&lt;/id&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;single&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;phase&gt;package&lt;/phase&gt;
                      &lt;configuration&gt;
                          &lt;descriptors&gt;
                              &lt;descriptor&gt;assembly.xml&lt;/descriptor&gt;
                          &lt;/descriptors&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>And my assembly.xml looks like this:</p>
  
  <pre><code>&lt;assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"&gt;
      &lt;id&gt;bundle&lt;/id&gt;
      &lt;formats&gt;
          &lt;format&gt;jar&lt;/format&gt;
      &lt;/formats&gt;
      &lt;includeBaseDirectory&gt;false&lt;/includeBaseDirectory&gt;
      &lt;moduleSets&gt;
          &lt;moduleSet&gt;
              &lt;useAllReactorProjects&gt;true&lt;/useAllReactorProjects&gt;
              &lt;binaries&gt;
                  &lt;outputDirectory&gt;modules&lt;/outputDirectory&gt;
                  &lt;unpack&gt;false&lt;/unpack&gt;
              &lt;/binaries&gt;
          &lt;/moduleSet&gt;
      &lt;/moduleSets&gt;
  &lt;/assembly&gt;
  </code></pre>