Search code examples
gradlegradle-tooling-api

External registration of Tooling API custom models


Both provided in samples/toolingApi/customModel and Feature Spotlight examples of Gradle Tooling API custom model use plugin to register the model. However in order to apply the plugin it's necessary to either change build.gradle or use initialization scripts, which are supported by GradleConnector (yet).

How can I register a custom model within Tooling API itself, so my application can retrieve projects' information in a custom format without changing their build.gradle files? How can I get a reference to ToolingModelBuilderRegistry implementation in an application code?


Solution

  • Init scripts are supported, they are just an argument like any other.

    projectConnection.models(ModelType).withArguments('--init-script', pathToInitScript).get()