Gradle 7.0 - put output jar from one submodule into another

I have Gradle 7 project & java 16, there are two sub modules

 - Root
   - sub project A
   - sub project B

My goal is following:

1) When project A is build it creates a A.jar file.
2) When project B is build it creates a B.jar file that contains an unexploded A.jar output from build of project A

To be more clear B.jar should look something like this

\META-INF
\my
  \package
    \tree
      SomeClassInsideBJar.class
\A.jar
URI aJarUri = someClassInsideBjar.getClassLaoder().getResource("A.jar");

Subproject A build just fine, but i cannot figure out how to embed its output jar into B.jar

Please not that i do NOT want to add project A as dependency to project B. This is due to nature of project im working on. project B is a bootstrap for project A, but i do not want to bother you with details.

in a nutshell i do not want this in project B

dependencies{
   compile (':A')
}

I’m going to assume that means you don’t want a compile/runtime dependency but that different kinds of dependencies are allowed.

In B:

configurations {
    embeddedJars
}
dependencies {
    embeddedJars project( ':A' )
}
jar {
    from( configurations.embeddedJars )
}

Note: this will also include transitive dependencies on A’s runtimeClasspath.