Creating custom tooling model

I would like to use the gradle tooling API to register a new ToolingModel using the ToolingModelBuilderRegistry.
I created a simple implementation of ToolingModelBuilder as follow:

public class CustomToolingModelBuilder implements ToolingModelBuilder {

    public boolean canBuild(String modelName) {
        return modelName.equals(CustomWorkspace.class.getName());

    public Object buildAll(String modelName, Project project) {
        return new CustomWorkspaceImpl(project);

Each time I try to access my model using the GradleConnector:

ProjectConnection connection = GradleConnector.newConnector()
ModelBuilder<CustomWorkspace> modelBuilder = connection.model(CustomWorkspace.class);
CustomWorkspace workspace = modelBuilder.get();

It ends up with the following error:

No model of type 'CustomWorkspace' is available in this build.
org.gradle.tooling.UnknownModelException: No model of type 'CustomWorkspace' is available in this build.

The injected registry in my plugin seems to have a parent registry which contains other model (idea, eclipse, cpp, …) I’m not sure if my model is registered in the right registry.

Actually, I found the solution. My project had multiple issues such as:

  • My model implementation was not Serializable
  • My model was not returning interface

Fixing those isssues make it works!