Uber JAR with Maven

By default maven is generating a small JAR file, which just contains your compiled classes and other project files. If you want to have a single JAR file which also includes all dependent JAR files, you have to create a uber JAR. You can do that with the maven shade plugin. Just put this lines of xml into your pom.xml.

</pre>
<build>
<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
	<version>1.4</version>
	<executions>
	  <execution>
	    <phase>package</phase>
	    <goals>
	      <goal>shade</goal>
	    </goals>
	    <configuration>
	      <shadedArtifactAttached>true</shadedArtifactAttached>
	      <shadedClassifierName>all</shadedClassifierName>
	    </configuration>
	  </execution>
	</executions>
      </plugin>
   </plugins>
 </build>
<pre>

In Maven you can solve every problem. You just need enough XML code for that. If you still have problems, than probably your pom.xml is to short. 🙂

3 thoughts on “Uber JAR with Maven

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s