use of org.gradle.tooling.provider.model.ParameterizedToolingModelBuilder in project gradle by gradle.
the class DefaultBuildController method getModel.
/**
* This is used by consumers 4.4 and later
*/
public BuildResult<?> getModel(Object target, ModelIdentifier modelIdentifier, Object parameter) throws BuildExceptionVersion1, InternalUnsupportedModelException {
BuildCancellationToken cancellationToken = gradle.getServices().get(BuildCancellationToken.class);
if (cancellationToken.isCancellationRequested()) {
throw new BuildCancelledException(String.format("Could not build '%s' model. Build cancelled.", modelIdentifier.getName()));
}
ProjectInternal project = getTargetProject(target);
ToolingModelBuilder builder = getToolingModelBuilder(project, modelIdentifier);
String modelName = modelIdentifier.getName();
Object model;
if (parameter == null) {
model = builder.buildAll(modelName, project);
} else if (builder instanceof ParameterizedToolingModelBuilder<?>) {
model = getParameterizedModel(project, modelName, (ParameterizedToolingModelBuilder<?>) builder, parameter);
} else {
throw (InternalUnsupportedModelException) (new InternalUnsupportedModelException()).initCause(new UnknownModelException(String.format("No parameterized builders are available to build a model of type '%s'.", modelName)));
}
return new ProviderBuildResult<Object>(model);
}
Aggregations