Search in sources :

Example 1 with ClientProvidedBuildAction

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

the class ClientProvidedBuildActionRunner method run.

@Override
public void run(BuildAction action, final BuildController buildController) {
    if (!(action instanceof ClientProvidedBuildAction)) {
        return;
    }
    final GradleInternal gradle = buildController.getGradle();
    gradle.getStartParameter().setConfigureOnDemand(false);
    ClientProvidedBuildAction clientProvidedBuildAction = (ClientProvidedBuildAction) action;
    PayloadSerializer payloadSerializer = getPayloadSerializer(gradle);
    final Object clientAction = payloadSerializer.deserialize(clientProvidedBuildAction.getAction());
    gradle.addBuildListener(new BuildAdapter() {

        @Override
        public void buildFinished(BuildResult result) {
            if (result.getFailure() == null) {
                buildController.setResult(buildResult(clientAction, gradle));
            }
        }
    });
    if (clientProvidedBuildAction.isRunTasks()) {
        buildController.run();
    } else {
        buildController.configure();
    }
}
Also used : GradleInternal(org.gradle.api.internal.GradleInternal) BuildResult(org.gradle.BuildResult) PayloadSerializer(org.gradle.tooling.internal.provider.serialization.PayloadSerializer) ClientProvidedBuildAction(org.gradle.tooling.internal.provider.ClientProvidedBuildAction) BuildAdapter(org.gradle.BuildAdapter)

Aggregations

BuildAdapter (org.gradle.BuildAdapter)1 BuildResult (org.gradle.BuildResult)1 GradleInternal (org.gradle.api.internal.GradleInternal)1 ClientProvidedBuildAction (org.gradle.tooling.internal.provider.ClientProvidedBuildAction)1 PayloadSerializer (org.gradle.tooling.internal.provider.serialization.PayloadSerializer)1