I’d like Maven to package a project alongside its run-time dependencies. I expect it to create a JAR file with the following manifest:
.....
Main-Class : com.acme.MainClass
Class-Path : lib/dependency1.jar lib/dependency2.jar
.....
and create the following directory structure:
target
|-- ....
|-- my-project.jar
|-- lib
|-- dependency1.jar
|-- dependency2.jar
Meaning, I want the main JAR to exclude any dependencies and I want all transitive dependencies to get copied into a “lib” sub-directory. Any ideas?
This part is unclear (it’s not exactly what you describe just after). My answer covers what you described.
Configure the Maven Jar Plugin to do so (or more precisely, the Maven Archiver):
And this will produce a MANIFEST.MF with the following entries:
This is doable using the Maven Dependency Plugin and the
dependency:copy-dependenciesgoal. From the documentation:You could bind it on the
packagephase: