title: How do you create a standalone application with dependencies intact using Maven?
body: <p>I have a desktop Java application built using Maven 2 (but I could upgrade to Maven 3 if that helps) with a number of open source dependencies. I'm now trying to package it up as a standalone to make it available to end users without them needing to install maven or anything else. </p>
  
  <p>I've successfully used maven-assembly-plugin to build a single jar containing all dependencies but this is not really what I want because when using LGPL libraries you are meant to redistribute the libraries you are using as separate jars. </p>
  
  <p>I want Maven to build a zip containing a jar with my code and a <code>MANIFEST.MF</code> that refers to the other jars I need together with the other jars. This seems like standard practice but I cannot see how to do it.</p>
  
  <p>Here's an extract from my pom</p>
  
  
  
  <pre class="lang-xml prettyprint-override"><code>     &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;encoding&gt;UTF-8&lt;/encoding&gt;
                      &lt;compilerVersion&gt;1.6&lt;/compilerVersion&gt;
                      &lt;source&gt;1.6&lt;/source&gt;
                      &lt;target&gt;1.6&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;argLine&gt;-Dfile.encoding=UTF-8&lt;/argLine&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &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.4&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;archive&gt;
                          &lt;manifest&gt;
                              &lt;mainClass&gt;com.company.widget.Main&lt;/mainClass&gt;
                              &lt;packageName&gt;com.company.widget&lt;/packageName&gt;
                              &lt;addClasspath&gt;true&lt;/addClasspath&gt;
                          &lt;/manifest&gt;
                      &lt;/archive&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.3&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;com.company.widget.Main&lt;/mainClass&gt;
                              &lt;packageName&gt;com.company.widget&lt;/packageName&gt;
                              &lt;addClasspath&gt;true&lt;/addClasspath&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;
          &lt;/plugins&gt;
      &lt;/build&gt; 
  </code></pre>
  
  <p>EDIT:Taken on Kals idea</p>
  
  <p>created a file called descriptor.xml</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;assembly
      xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"&gt;
      &lt;id&gt;distribution&lt;/id&gt;
      &lt;formats&gt;
          &lt;format&gt;zip&lt;/format&gt;
      &lt;/formats&gt;
      &lt;dependencySets&gt;
          &lt;dependencySet&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
              &lt;outputDirectory&gt;lib&lt;/outputDirectory&gt;
              &lt;unpack&gt;false&lt;/unpack&gt;
          &lt;/dependencySet&gt;
      &lt;/dependencySets&gt;
  &lt;/assembly&gt;
  </code></pre>
  
  <p>and pom contains:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
      &lt;version&gt;2.3&lt;/version&gt;
      &lt;configuration&gt;
          &lt;descriptors&gt;
              &lt;descriptor&gt;assembly.xml&lt;/descriptor&gt;
          &lt;/descriptors&gt;
          &lt;archive&gt;
              &lt;manifest&gt;
                  &lt;mainClass&gt;com.company.widget.cmdline.Main&lt;/mainClass&gt;
                  &lt;packageName&gt;com.company.widget&lt;/packageName&gt;
                  &lt;addClasspath&gt;true&lt;/addClasspath&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>Now maintains the jar and puts them all in the lib folder, including my own code</p>