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());
}
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;
}
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());
}
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());
}
Aggregations