How can I create single jar by referencing local jars in "/lib"

I’m trying to create single jar by referencing local jars in “/lib”, but it can’t find local jar in “/lib”

I wrote “build.gradle” in Eclipse project folder, but I don’t use eclipse plugin(use java plugin)

what I want is after build it “result.jar” and " /lib(where jars located)" are created

Here’s my source

Is there something wrong?

apply plugin: 'java'
  sourceSets {
        java.srcDir 'src'
  dependencies {
 compile fileTree(dir: 'lib', include: '*.jar')
    manifest {
        attributes 'Main-Class': 'com.ServerManager'

There are generally 2 ways of handling this:

  • Extract all files in the jars under lib/ into result.jar - Use something like one-jar to create a classloader that handles loading classes from inside jar-files inside a jar-file

There are already plugins that can be used for doing any of these. Look at this discussion for more info:


Are you trying to combine all the jars in lib/ into a single Jar? If so you need to use a ZipTree task to expand all of the jars so it can pull them into your output jar.