How to add jars into a jar?

(Carlo Luib-Finetti) #1

I have to build some jars which are Eclipse plugins containing dependent library jars within a ‘lib’ directory.

When I override the ‘jar’-task like this:

jar {
    from "${projectDir}/lib"

the dependent jars will be include, but into the root directory of the target jar.

And when I do this: jar {

from “${projectDir}/lib”

into ‘lib’ } I get a ‘lib’ directory, but the compiled classes will also be found there.

How do I get the compiled classes in the normal order of a jar, plus an additional directory ‘lib’ for my libs’?

(crotwell) #2

You might try:

jar {
   from("$projectDir") {
      include 'lib/**'

This way you put the whole lib directory recursively into the jar but do not change the “into”.


(Carlo Luib-Finetti) #3

Thanks Philip, this now works as expected!