

Maven assembly plugin provide facility to Maven create jar with all dependencies. Here is maven plugin which create fat jar file that contains all dependency jar files in single jar file.
<plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>com.javadeveloperzone1.Demo</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </plugin> </plugins>
execute following command : mvn clean compile assembly:single
[INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building com.javadeveloperzone 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ com.javadeveloperzone --- [INFO] Deleting F:\extrawork\java9-demo\module-stream-demo\target [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ com.javadeveloperzone --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.6.0:compile (default-compile) @ com.javadeveloperzone --- [INFO] Changes detected - recompiling the module! [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 37 source files to F:\extrawork\java9-demo\module-stream-demo\target\classes [INFO] /F:/extrawork/java9-demo/module-stream-demo/src/main/java/com/javadeveloperzone1/TestDemo.java: Some input files use unchecked or unsafe operations. [INFO] /F:/extrawork/java9-demo/module-stream-demo/src/main/java/com/javadeveloperzone1/TestDemo.java: Recompile with -Xlint:unchecked for details. [INFO] [INFO] --- maven-assembly-plugin:3.0.0:single (default-cli) @ com.javadeveloperzone --- [INFO] Building jar: F:\extrawork\java9-demo\module-stream-demo\target\com.javadeveloperzone-1.0-SNAPSHOT-jar-with-dependencies.jar [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS
Table of Contents
New jar with all dependencies

maven create jar with all dependencies
References:
maven assembly plugin document
Was this post helpful?
Let us know if you liked the post. That’s the only way we can improve.