How can I use the tooling api to get internal and external dependencies?


(Kim Betti) #1

The tooling documentation says that it should be possible to get internal and external dependencies, but I can’t figure out to do that without invoking a task and parsing the output…

“You can query Gradle for the details of a build, including the project hierarchy and the project dependencies, external dependencies (including source and javadoc jars), source directories and tasks of each project.”


(Radim Kubacki) #2

At the moment there are several models available that expose various types of information - http://www.gradle.org/docs/current/javadoc/org/gradle/tooling/ProjectConnection.html#model(java.lang.Class)

Some of them are general and give you a model based on Gradle concepts and others are more tailored to IDEs like IntelliJ or Eclipse. If this is not sufficient for you you can create your own model build and expose the data from Gradle through tooling API with it. There is a sample in Gradle distribution showing how to start such a project.


(Kim Betti) #3

Oh, that was an amazingly quick reply! Thanks!

So if I want to extract dependencies between projects in the same build I have to dig into either the Eclipse or Idea models? It’s fine if that is the case, it just confused me that this information was not available via GradeProject.

Have a nice summer!


(Radim Kubacki) #4

Yes, either one of these models or write your own. You can look at the sources of these two models in the repository. Although not everything is public API what is used to build these models.