Search in sources :

Example 1 with InternalUnsupportedModelException

use of org.gradle.tooling.internal.protocol.InternalUnsupportedModelException in project gradle by gradle.

the class ModelBuilderBackedModelProducer method produceModel.

public <T> T produceModel(Class<T> type, ConsumerOperationParameters operationParameters) {
    if (!versionDetails.maySupportModel(type)) {
        throw Exceptions.unsupportedModel(type, versionDetails.getVersion());
    }
    final ModelIdentifier modelIdentifier = modelMapping.getModelIdentifierFromModelType(type);
    BuildResult<?> result;
    try {
        result = builder.getModel(modelIdentifier, operationParameters);
    } catch (InternalUnsupportedModelException e) {
        throw Exceptions.unknownModel(type, e);
    }
    return applyCompatibilityMapping(adapter.builder(type), operationParameters).build(result.getModel());
}
Also used : InternalUnsupportedModelException(org.gradle.tooling.internal.protocol.InternalUnsupportedModelException) ModelIdentifier(org.gradle.tooling.internal.protocol.ModelIdentifier)

Example 2 with InternalUnsupportedModelException

use of org.gradle.tooling.internal.protocol.InternalUnsupportedModelException in project gradle by gradle.

the class DefaultBuildController method getToolingModelBuilder.

private ToolingModelBuilder getToolingModelBuilder(ProjectInternal project, ModelIdentifier modelIdentifier) {
    ToolingModelBuilderRegistry modelBuilderRegistry = project.getServices().get(ToolingModelBuilderRegistry.class);
    ToolingModelBuilder builder;
    try {
        builder = modelBuilderRegistry.getBuilder(modelIdentifier.getName());
    } catch (UnknownModelException e) {
        throw (InternalUnsupportedModelException) (new InternalUnsupportedModelException()).initCause(e);
    }
    return builder;
}
Also used : InternalUnsupportedModelException(org.gradle.tooling.internal.protocol.InternalUnsupportedModelException) ToolingModelBuilderRegistry(org.gradle.tooling.provider.model.ToolingModelBuilderRegistry) UnknownModelException(org.gradle.tooling.provider.model.UnknownModelException) ToolingModelBuilder(org.gradle.tooling.provider.model.ToolingModelBuilder)

Example 3 with InternalUnsupportedModelException

use of org.gradle.tooling.internal.protocol.InternalUnsupportedModelException in project gradle by gradle.

the class BuildControllerAdapter method getModel.

public <T> T getModel(Model target, Class<T> modelType) throws UnknownModelException {
    ModelIdentifier modelIdentifier = modelMapping.getModelIdentifierFromModelType(modelType);
    Object originalTarget = target == null ? null : adapter.unpack(target);
    BuildResult<?> result;
    try {
        result = buildController.getModel(originalTarget, modelIdentifier);
    } catch (InternalUnsupportedModelException e) {
        throw Exceptions.unknownModel(modelType, e);
    }
    ViewBuilder<T> viewBuilder = resultAdapter.builder(modelType);
    applyCompatibilityMapping(viewBuilder, new DefaultProjectIdentifier(rootDir, getProjectPath(target)));
    return viewBuilder.build(result.getModel());
}
Also used : InternalUnsupportedModelException(org.gradle.tooling.internal.protocol.InternalUnsupportedModelException) ModelIdentifier(org.gradle.tooling.internal.protocol.ModelIdentifier) DefaultProjectIdentifier(org.gradle.tooling.internal.gradle.DefaultProjectIdentifier)

Example 4 with InternalUnsupportedModelException

use of org.gradle.tooling.internal.protocol.InternalUnsupportedModelException in project gradle by gradle.

the class CancellableModelBuilderBackedModelProducer method produceModel.

public <T> T produceModel(Class<T> type, ConsumerOperationParameters operationParameters) {
    if (!versionDetails.maySupportModel(type)) {
        throw Exceptions.unsupportedModel(type, versionDetails.getVersion());
    }
    final ModelIdentifier modelIdentifier = modelMapping.getModelIdentifierFromModelType(type);
    BuildResult<?> result;
    try {
        result = builder.getModel(modelIdentifier, new BuildCancellationTokenAdapter(operationParameters.getCancellationToken()), operationParameters);
    } catch (InternalUnsupportedModelException e) {
        throw Exceptions.unknownModel(type, e);
    } catch (RuntimeException e) {
        throw exceptionTransformer.transform(e);
    }
    return applyCompatibilityMapping(adapter.builder(type), operationParameters).build(result.getModel());
}
Also used : InternalUnsupportedModelException(org.gradle.tooling.internal.protocol.InternalUnsupportedModelException) ModelIdentifier(org.gradle.tooling.internal.protocol.ModelIdentifier) BuildCancellationTokenAdapter(org.gradle.tooling.internal.consumer.parameters.BuildCancellationTokenAdapter)

Aggregations

InternalUnsupportedModelException (org.gradle.tooling.internal.protocol.InternalUnsupportedModelException)4 ModelIdentifier (org.gradle.tooling.internal.protocol.ModelIdentifier)3 BuildCancellationTokenAdapter (org.gradle.tooling.internal.consumer.parameters.BuildCancellationTokenAdapter)1 DefaultProjectIdentifier (org.gradle.tooling.internal.gradle.DefaultProjectIdentifier)1 ToolingModelBuilder (org.gradle.tooling.provider.model.ToolingModelBuilder)1 ToolingModelBuilderRegistry (org.gradle.tooling.provider.model.ToolingModelBuilderRegistry)1 UnknownModelException (org.gradle.tooling.provider.model.UnknownModelException)1