Search in sources :

Example 1 with ToolingModelBuilder

use of org.gradle.tooling.provider.model.ToolingModelBuilder in project gradle by gradle.

the class DefaultBuildController method getModel.

public BuildResult<?> getModel(Object target, ModelIdentifier modelIdentifier) throws BuildExceptionVersion1, InternalUnsupportedModelException {
    BuildCancellationToken cancellationToken = gradle.getServices().get(BuildCancellationToken.class);
    if (cancellationToken.isCancellationRequested()) {
        throw new BuildCancelledException(String.format("Could not build '%s' model. Build cancelled.", modelIdentifier.getName()));
    }
    ProjectInternal project = getTargetProject(target);
    ToolingModelBuilder builder = getToolingModelBuilder(project, modelIdentifier);
    Object model = builder.buildAll(modelIdentifier.getName(), project);
    return new ProviderBuildResult<Object>(model);
}
Also used : ProjectInternal(org.gradle.api.internal.project.ProjectInternal) ProviderBuildResult(org.gradle.tooling.internal.provider.connection.ProviderBuildResult) BuildCancellationToken(org.gradle.initialization.BuildCancellationToken) ToolingModelBuilder(org.gradle.tooling.provider.model.ToolingModelBuilder) BuildCancelledException(org.gradle.api.BuildCancelledException)

Example 2 with ToolingModelBuilder

use of org.gradle.tooling.provider.model.ToolingModelBuilder 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)

Aggregations

ToolingModelBuilder (org.gradle.tooling.provider.model.ToolingModelBuilder)2 BuildCancelledException (org.gradle.api.BuildCancelledException)1 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)1 BuildCancellationToken (org.gradle.initialization.BuildCancellationToken)1 InternalUnsupportedModelException (org.gradle.tooling.internal.protocol.InternalUnsupportedModelException)1 ProviderBuildResult (org.gradle.tooling.internal.provider.connection.ProviderBuildResult)1 ToolingModelBuilderRegistry (org.gradle.tooling.provider.model.ToolingModelBuilderRegistry)1 UnknownModelException (org.gradle.tooling.provider.model.UnknownModelException)1