How to create a bundle jar enclosing another jar as a file inside it

We currently have a maven build that generates a agent-bundle jar which contains main agent jar as a file inside it. Below is the maven build configuration to achieve this. How can I achieve the same with gradle? dependency is coming from a sub module in the same project which is at the same level as agent-bundle sub module.

<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">

You can create new resolvable configuration, add a dependency on your jar just to it in the dependencies block and modify your just task to include it:

val agent by configurations.registering {
  isCanBeConsumed = false
  isCanBeResolved = true

dependencies {

tasks.jar {

That worked. Thank you @grossws