How can I create an executable JAR with dependencies using Maven?

I want to package my project in a single executable JAR for distribution.

How can I make Maven package all dependency JARs into my JAR?


and you run it with

Compile goal should be added before assembly:single or otherwise the code on your own project is not included.

See more details in comments.


Commonly this goal is tied to a build phase to execute automatically. This ensures the JAR is built when executing mvn install or performing a deployment/release.