use of org.gradle.tooling.internal.protocol.ModelIdentifier in project gradle by gradle.
the class UnparameterizedBuildController method getModel.
@Override
public <T, P> T getModel(Model target, Class<T> modelType, Class<P> parameterType, Action<? super P> parameterInitializer) throws UnsupportedVersionException, UnknownModelException {
ModelIdentifier modelIdentifier = modelMapping.getModelIdentifierFromModelType(modelType);
Object originalTarget = target == null ? null : adapter.unpack(target);
P parameter = initializeParameter(parameterType, parameterInitializer);
BuildResult<?> result;
try {
result = getModel(originalTarget, modelIdentifier, parameter);
} 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.ModelIdentifier in project gradle by gradle.
the class CancellableModelBuilderBackedModelProducer method produceModel.
@Override
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