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:
ModelBuilder<OutgoingArtifactsModel> customModelBuilder = connection.model(OutgoingArtifactsModel.class);
customModelBuilder.withArguments("--init-script", copyInitScript().getAbsolutePath());
OutgoingArtifactsModel model = customModelBuilder.get();
for (File artifact : model.getArtifacts()) {
System.out.println("artifact = " + artifact);
}
If you want to list plugins you can use the project.getPlugins()
API.