Search in sources :

Example 1 with ClientProvidedBuildAction

use of org.gradle.tooling.internal.provider.action.ClientProvidedBuildAction in project gradle by gradle.

the class ClientProvidedBuildActionRunner method run.

@Override
public Result run(BuildAction action, BuildTreeLifecycleController buildController) {
    if (!(action instanceof ClientProvidedBuildAction)) {
        return Result.nothing();
    }
    ClientProvidedBuildAction clientProvidedBuildAction = (ClientProvidedBuildAction) action;
    Object clientAction = payloadSerializer.deserialize(clientProvidedBuildAction.getAction());
    return runClientAction(new ClientActionImpl(clientAction, action), buildController);
}
Also used : ClientProvidedBuildAction(org.gradle.tooling.internal.provider.action.ClientProvidedBuildAction)

Example 2 with ClientProvidedBuildAction

use of org.gradle.tooling.internal.provider.action.ClientProvidedBuildAction in project gradle by gradle.

the class ProviderConnection method runClientAction.

public Object runClientAction(Object clientAction, BuildCancellationToken cancellationToken, ProviderOperationParameters providerParameters) {
    List<String> tasks = providerParameters.getTasks();
    SerializedPayload serializedAction = payloadSerializer.serialize(clientAction);
    Parameters params = initParams(providerParameters);
    StartParameterInternal startParameter = new ProviderStartParameterConverter().toStartParameter(providerParameters, params.buildLayout, params.properties);
    ProgressListenerConfiguration listenerConfig = ProgressListenerConfiguration.from(providerParameters, consumerVersion);
    BuildAction action = new ClientProvidedBuildAction(startParameter, serializedAction, tasks != null, listenerConfig.clientSubscriptions);
    return run(action, cancellationToken, listenerConfig, listenerConfig.buildEventConsumer, providerParameters, params);
}
Also used : SerializedPayload(org.gradle.tooling.internal.provider.serialization.SerializedPayload) ProviderConnectionParameters(org.gradle.tooling.internal.provider.connection.ProviderConnectionParameters) ProviderOperationParameters(org.gradle.tooling.internal.provider.connection.ProviderOperationParameters) DaemonParameters(org.gradle.launcher.daemon.configuration.DaemonParameters) BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) ClientProvidedBuildAction(org.gradle.tooling.internal.provider.action.ClientProvidedBuildAction) StartParameterInternal(org.gradle.api.internal.StartParameterInternal) ClientProvidedBuildAction(org.gradle.tooling.internal.provider.action.ClientProvidedBuildAction) BuildAction(org.gradle.internal.invocation.BuildAction)

Example 3 with ClientProvidedBuildAction

use of org.gradle.tooling.internal.provider.action.ClientProvidedBuildAction in project gradle by gradle.

the class BuildTreeLifecycleBuildActionExecutor method execute.

@Override
public BuildActionRunner.Result execute(BuildAction action, BuildSessionContext buildSession) {
    BuildActionRunner.Result result = null;
    try {
        buildLayoutValidator.validate(action.getStartParameter());
        BuildActionModelRequirements actionRequirements;
        if (action instanceof BuildModelAction && action.isCreateModel()) {
            BuildModelAction buildModelAction = (BuildModelAction) action;
            actionRequirements = new QueryModelRequirements(action.getStartParameter(), action.isRunTasks(), buildModelAction.getModelName());
        } else if (action instanceof ClientProvidedBuildAction) {
            actionRequirements = new RunActionRequirements(action.getStartParameter(), action.isRunTasks());
        } else if (action instanceof ClientProvidedPhasedAction) {
            actionRequirements = new RunPhasedActionRequirements(action.getStartParameter(), action.isRunTasks());
        } else {
            actionRequirements = new RunTasksRequirements(action.getStartParameter());
        }
        BuildTreeModelControllerServices.Supplier modelServices = buildTreeModelControllerServices.servicesForBuildTree(actionRequirements);
        BuildTreeState buildTree = new BuildTreeState(buildSession.getServices(), modelServices);
        try {
            result = buildTree.run(context -> context.execute(action));
        } finally {
            buildTree.close();
        }
    } catch (Throwable t) {
        if (result == null) {
            // whereas console failure logging based on the _thrown exception_ happens up outside session scope. It would be better to refactor so that a result can be returned from here
            throw UncheckedException.throwAsUncheckedException(t);
        } else {
            // whereas console failure logging based on the _thrown exception_ happens up outside session scope. It would be better to refactor so that a result can be returned from here
            throw UncheckedException.throwAsUncheckedException(result.addFailure(t).getBuildFailure());
        }
    }
    return result;
}
Also used : BuildActionRunner(org.gradle.internal.buildtree.BuildActionRunner) BuildTreeState(org.gradle.internal.buildtree.BuildTreeState) BuildActionModelRequirements(org.gradle.internal.buildtree.BuildActionModelRequirements) ClientProvidedBuildAction(org.gradle.tooling.internal.provider.action.ClientProvidedBuildAction) BuildTreeModelControllerServices(org.gradle.internal.buildtree.BuildTreeModelControllerServices) ClientProvidedPhasedAction(org.gradle.tooling.internal.provider.action.ClientProvidedPhasedAction) BuildSessionActionExecutor(org.gradle.internal.session.BuildSessionActionExecutor) UncheckedException(org.gradle.internal.UncheckedException) RunTasksRequirements(org.gradle.internal.buildtree.RunTasksRequirements) BuildAction(org.gradle.internal.invocation.BuildAction) BuildSessionContext(org.gradle.internal.session.BuildSessionContext) BuildModelAction(org.gradle.tooling.internal.provider.action.BuildModelAction) BuildLayoutValidator(org.gradle.internal.build.BuildLayoutValidator) ClientProvidedPhasedAction(org.gradle.tooling.internal.provider.action.ClientProvidedPhasedAction) BuildActionModelRequirements(org.gradle.internal.buildtree.BuildActionModelRequirements) BuildTreeState(org.gradle.internal.buildtree.BuildTreeState) BuildActionRunner(org.gradle.internal.buildtree.BuildActionRunner) ClientProvidedBuildAction(org.gradle.tooling.internal.provider.action.ClientProvidedBuildAction) BuildTreeModelControllerServices(org.gradle.internal.buildtree.BuildTreeModelControllerServices) RunTasksRequirements(org.gradle.internal.buildtree.RunTasksRequirements) BuildModelAction(org.gradle.tooling.internal.provider.action.BuildModelAction)

Aggregations

ClientProvidedBuildAction (org.gradle.tooling.internal.provider.action.ClientProvidedBuildAction)3 BuildAction (org.gradle.internal.invocation.BuildAction)2 StartParameterInternal (org.gradle.api.internal.StartParameterInternal)1 UncheckedException (org.gradle.internal.UncheckedException)1 BuildLayoutValidator (org.gradle.internal.build.BuildLayoutValidator)1 BuildActionModelRequirements (org.gradle.internal.buildtree.BuildActionModelRequirements)1 BuildActionRunner (org.gradle.internal.buildtree.BuildActionRunner)1 BuildTreeModelControllerServices (org.gradle.internal.buildtree.BuildTreeModelControllerServices)1 BuildTreeState (org.gradle.internal.buildtree.BuildTreeState)1 RunTasksRequirements (org.gradle.internal.buildtree.RunTasksRequirements)1 BuildSessionActionExecutor (org.gradle.internal.session.BuildSessionActionExecutor)1 BuildSessionContext (org.gradle.internal.session.BuildSessionContext)1 DaemonParameters (org.gradle.launcher.daemon.configuration.DaemonParameters)1 BuildActionParameters (org.gradle.launcher.exec.BuildActionParameters)1 BuildModelAction (org.gradle.tooling.internal.provider.action.BuildModelAction)1 ClientProvidedPhasedAction (org.gradle.tooling.internal.provider.action.ClientProvidedPhasedAction)1 ProviderConnectionParameters (org.gradle.tooling.internal.provider.connection.ProviderConnectionParameters)1 ProviderOperationParameters (org.gradle.tooling.internal.provider.connection.ProviderOperationParameters)1 SerializedPayload (org.gradle.tooling.internal.provider.serialization.SerializedPayload)1