Include project in two other projects

I have a git repository that its root directory has the following structure


each of them is a Gradle project.
I want that projectA and projectB will have a code dependency on common project, as if, let’s say, it was a subproject of both them. (or any other code dependency).

What’s the best way to achieve that?

This URL does not help me with the situation i described unless i am missing something.
The root directory i mentioned is not a gradle project, but just a “container” to contain other gradle projets.
Project A, B and Common are independent projects at the moment.

It seems to me like the link describes your use case

Why don’t you make it a multi-project build? Seems like the simplest solution to me, then you could do it as described on the linked page.

If you really need to make it separate Gradle builds, I’d let the common project publish its artifact to a Maven repo inside the build directory of the common project. Then add that repository to the other two projects and define a dependency on it.