Object result;
if (builder instanceof ProjectSensitiveToolingModelBuilder) {
result = ((ProjectSensitiveToolingModelBuilder) builder).buildAll(modelName, gradle.getDefaultProject(), true);
} else {
result = builder.buildAll(modelName, gradle.getDefaultProject());
}
PayloadSerializer payloadSerializer = gradle.getServices().get(PayloadSerializer.class);
return new BuildActionResult(payloadSerializer.serialize(result), null);
}