use of org.gradle.tooling.provider.model.internal.ToolingModelScope in project gradle by gradle.
the class DefaultBuildController method getModel.
/**
* This is used by consumers 4.4 and later
*/
@Override
public BuildResult<?> getModel(@Nullable Object target, ModelIdentifier modelIdentifier, Object parameter) throws BuildExceptionVersion1, InternalUnsupportedModelException {
assertCanQuery();
if (cancellationToken.isCancellationRequested()) {
throw new BuildCancelledException(String.format("Could not build '%s' model. Build cancelled.", modelIdentifier.getName()));
}
ToolingModelScope scope = getTarget(target, modelIdentifier, parameter != null);
Object model;
try {
if (parameter == null) {
model = scope.getModel(modelIdentifier.getName(), null);
} else {
model = scope.getModel(modelIdentifier.getName(), parameterFactory(parameter));
}
} catch (UnknownModelException e) {
throw (InternalUnsupportedModelException) new InternalUnsupportedModelException().initCause(e);
}
return new ProviderBuildResult<>(model);
}
Aggregations