Merging archive into jar

(Ingo Randolf) #1


i need to merge an existing jar-file into the output jar using the jar-task.

doing this copies the .jar file into the resulting jar:

jar {
    from {

i need to basically do what the shadow-plugin does. the problem with the shadow-plugin is, that i need to keep my dependencies (which are getting erased from the POM when using the shadow-plugin)

is there a way to merge the classes of an existing .jar-file into the resulting library using the jar-task?
or: is it possbile to keep dependencies when using the shadow-plugin?

thanks for any hints.

(Mark Vieira) #2

Yep. The trick here is that you want to include the contents of the other JAR, not the JAR itself. To do this you’ll want to leverage the zipTree() method.

jar {
    from zipTree('path/to/myjar.jar')

(Ingo Randolf) #3

thank your very much!
worked like a charm.

that saved my day (and it just started…) :smile: