This entry is part rant and part sharing the knowledge. For the record I think that Maven 1.x sucks, and if it was not for the excellent Better Builds with Maven book I would not be using Maven 2.

There is a lot to like about Maven 2, in particular I use the maven-eclipse-plugin to generate Eclipse projects, and the integration with the Jetty plug-in for doing rapid webapp development totally rocks. The maven-site-plugin is great for making you feel like you are creating documentation. :-)

But things get (unnecessarily?) hard when you try and doing things that Maven does not support out of the box. Yesterday I was trying to generate an standalone executable JAR file for my project, the type that is simple to generate using the Fat Jar Eclipse Plug-In. This type of JAR file includes all the required dependencies. This makes distribution a breeze.

First up I tried to use maven-jar-plugin and followed the instructions in Creating an executable jar file. This was not successful as it does not include the required dependencies, but instead creates a manifest entry to refer to them.

Next attempt involved trying to use the maven-assembly-plugin with the predefined assembly jar-with-dependencies. This attempt failed as the plug-in does not keep the `Main-Class:` entry in the manifest, but it did however include the dependencies as advertised.

My third attempt was to use the minijar-maven-plugin and hopefully get the added benefit of a smaller JAR file. Unfortunately it just generated a corrupt JAR file.

Next up was the proguard-maven-plugin. Basically I was unable to get it to run successfully, despite my repeated attempts.

Finally up was onejar-maven-plugin. Initially the generated JAR file did not work as when run it would hang. I realised that I was missing the manifest entry in my pom.xml. Once this was added, it worked like a charm.

Hopefully this blog will save people some time. Here is what I finally had in my pom.xml: