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. 🙂

Published by Robert Reiz

CEO @ VersionEye. Passionated software developer since 1998.

4 thoughts on “Uber JAR with Maven

    1. It’s great your article helped me a lot.

      David I do not understand your answer, you can explain more clearly.Please

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 )

Facebook photo

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

Connecting to %s

%d bloggers like this: