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?

com.xyz.observability.agent:specialagent dependency is coming from a sub module in the same project which is at the same level as agent-bundle sub module.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <artifactId>agent-bundle</artifactId>
  <dependencies>
    <dependency>
      <groupId>com.xyz.observability.agent</groupId>
      <artifactId>specialagent</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.1.1</version>
        <executions>
          <execution>
            <id>copy-dependencies</id>
            <goals>
              <goal>copy</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>com.xyz.observability.agent</groupId>
                  <artifactId>specialagent</artifactId>
                  <type>jar</type>
                  <overWrite>true</overWrite>
                  <destFileName>xyz-specialagent.jar</destFileName>
                </artifactItem>
              </artifactItems>
              <outputDirectory>${project.build.outputDirectory}</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

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 {
  agent(project(":path:to:agent"))
}

tasks.jar {
  into("path/in/jar")
  from(agent)
}

That worked. Thank you @grossws