Search in sources :

Example 1 with ToolingModelScope

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);
}
Also used : InternalUnsupportedModelException(org.gradle.tooling.internal.protocol.InternalUnsupportedModelException) ToolingModelScope(org.gradle.tooling.provider.model.internal.ToolingModelScope) UnknownModelException(org.gradle.tooling.provider.model.UnknownModelException) ProviderBuildResult(org.gradle.tooling.internal.provider.connection.ProviderBuildResult) BuildCancelledException(org.gradle.api.BuildCancelledException)

Aggregations

BuildCancelledException (org.gradle.api.BuildCancelledException)1 InternalUnsupportedModelException (org.gradle.tooling.internal.protocol.InternalUnsupportedModelException)1 ProviderBuildResult (org.gradle.tooling.internal.provider.connection.ProviderBuildResult)1 UnknownModelException (org.gradle.tooling.provider.model.UnknownModelException)1 ToolingModelScope (org.gradle.tooling.provider.model.internal.ToolingModelScope)1