I am using Gradle tooling API to get different insights about Gradle projects such as project tasks, Gradle version, and more.
Part of this analysis requires me to know what plugins were applied (directly and transitively) by the project. I could not find a way to get Project’s plugins from the tooling API. Is there a way to do it?
The tooling API is limited in how you can query a build and there's no API to list build plugins, but the tooling API allows you to add your own plugins & models which you can use to query the build.
It's a little complex, but you need to add an init script to the build (eg via
init.gradle) to provide your custom model & plugin to query the build.This is a good repo that demonstrates how to do it: https://github.com/melix/gradle-tapi-demo-artifacts
Here's some code from that repo that demonstrates how to list build artifacts with a custom plugin & model:
If you want to list plugins you can use the
project.getPlugins()API.