0

I have below sample in build.gradle. My requirement is to include the jars jar1 (with its dependencies) and jar3 (with its dependencies) as part of my final jar. How can I do that ? I have searched a lot for this, although i found a solution here https://stackoverflow.com/a/43374638/1403009 but i can only include one package name as part of jar building task. In this case, I need multiple such packages/groups to be included as part of my final jar.

..
..
configurations {
    runTimeJars
}

dependencies {
  configurations.compile.extendsFrom(configurations.runTimeJars)
  runTimeJars'group1:jar1'
  compile 'group1:jar2'
  runTimeJars'group1:jar3'
}

jar {
    zip64 true
    from {
            configurations.runTimeJars.collect { it.isDirectory() ? it : zipTree(it) }
        }
}
Naveen
  • 830
  • 9
  • 19

1 Answers1

0

Try:

jar {
    manifest {
        attributes 'Main-Class': `mainClassName`
    }

    from {
        configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
        configurations.runTimeJars.collect { it.isDirectory() ? it : zipTree(it) }
    }
}

I didn't test it myself.

Anton Hlinisty
  • 1,441
  • 1
  • 20
  • 35
  • this will include all dependencies and resultant jar becomes fat jar. I need to include specific jar with its dependencies. – Naveen Oct 11 '18 at 20:00