pranjaljain
pranjaljain

Reputation: 180

Is there a way to bundle up multiple jars within the same jar file and make sure only one main jar inside it becomes part of classpath of the app

Is there a way to bundle up multiple jars within the same jar file and make sure only one main jar inside it becomes part of classpath of the application which adds this full jar into their classpath. Code inside my main jar will use a custom class loader to load classes present in other Jars in the full jar. I also want to create directory structure for other jars so that I can segregate jars based on use case and load only jars from a within directory inside the full jar.

Any help with any of the requirement above is appreciated. Thanks.

Upvotes: 1

Views: 1573

Answers (1)

Manoj2.0S
Manoj2.0S

Reputation: 31

you can use Maven Shade plugin because it is a better option to create jar within jar based on custom business logic, if compare with the maven assembly plugin, it provides a class relocating feature, to avoid the issues in the complex structure of the classpath.

sample shade plugin configuration

you can also use many transformations in Shade plugin from the below list as per your requirement.

Upvotes: 0

Related Questions