Java – With Maven, how can I build a distributable that has the project’s jar and all of the dependent jars


I have a project (of type 'jar') that (obviously) builds a jar. But that project has many dependencies. I'd like Maven to build a "package" or "assembly" that contains my jar, all the dependent jars, and some scripts (to launch the application, etc.)

What's the best way to go about this? Specifically, what's the best way to get the dependents into the assembly?

Best Solution

For a single module, I'd use an assembly looking like the following one (src/assembly/bin.xml):


To use this assembly, add the following configuration to your pom.xml:


In this sample, start/stop scripts located under src/main/command and are bundled into bin, dependencies are bundled into lib. Customize it to suit your needs.