Access dependencies from different gradle project in Java


I am facing a problem at accessing dependencies from a different gradle project in Java.

I do have two independent gradle projects named ProjectA and ProjectB.
Both projects have their own build.gradle, settings.gradle and files and are build on its own -> no multiproject build.

In ProjectA i do want to implement a custom gradle task, that receives a path and accesses the gradle project at that path and read its dependencies.
I did try the APIs org.gradle.api.Project.findProject(String path) and org.gradle.api.Project.project(String path) however both return null for the path to ProjectB.

I also had a look at the org.gradle.tooling.ProjectConnection API but couldn’t get the dependencies for my project ProjectB.

Is there any API I am missing?

Thanks in advance

These are only relevant to projects in a multi-project build.

You either need to publish Project B locally/remotely or utilize composite builds (which seems more like what you would want).

Thanks, I’ve already thought about setting up a multi-project-build for this.