Have Maven build a jar with all dependencies included



Published: 2021-08-10 09:50:12 +0000
Categories: Misc,

Language

Misc

Description

Maven is a software/dependency management tool for Java - it can be used to pull in dependencies and build a jar from a bunch of source

By default, the jar won't have dependencies rolled into it. Sometimes though, you want the overhead of the bigger jar.

Snippet

mvn assembly:assembly -DdescriptorId=jar-with-dependencies

Usage Example

mvn assembly:assembly -DdescriptorId=jar-with-dependencies
java -cp target/exampletest-1.0-SNAPSHOT-jar-with-dependencies.jar com.example.exampleorg.ExampleTestApp

Keywords

maven, java, dependencies, build, jar,

Latest Posts


Copyright © 2022 Ben Tasker | Sitemap | Privacy Policy
Available at snippets.bentasker.co.uk, http://phecoopwm6x7azx26ctuqcp6673bbqkrqfeoiz2wwk36sady5tqbdpqd.onion and http://snippets.bentasker.i2p
hit counter