Search in sources :

Example 1 with BuildOperationListener

use of org.gradle.internal.progress.BuildOperationListener in project gradle by gradle.

the class SubscribableBuildActionRunner method registerListenersForClientSubscriptions.

private void registerListenersForClientSubscriptions(BuildClientSubscriptions clientSubscriptions, GradleInternal gradle) {
    BuildEventConsumer eventConsumer = gradle.getServices().get(BuildEventConsumer.class);
    if (clientSubscriptions.isSendTestProgressEvents()) {
        registerListener(new ClientForwardingTestOperationListener(eventConsumer, clientSubscriptions));
    }
    if (!clientSubscriptions.isSendBuildProgressEvents() && !clientSubscriptions.isSendTaskProgressEvents()) {
        return;
    }
    BuildOperationListener buildListener = NO_OP;
    if (clientSubscriptions.isSendBuildProgressEvents()) {
        buildListener = new ClientForwardingBuildOperationListener(eventConsumer);
    }
    buildListener = new ClientForwardingTaskOperationListener(eventConsumer, clientSubscriptions, buildListener);
    registerListener(buildListener);
}
Also used : BuildEventConsumer(org.gradle.initialization.BuildEventConsumer) BuildOperationListener(org.gradle.internal.progress.BuildOperationListener)

Example 2 with BuildOperationListener

use of org.gradle.internal.progress.BuildOperationListener in project gradle by gradle.

the class SubscribableBuildActionRunner method run.

@Override
public void run(BuildAction action, BuildController buildController) {
    if (!(action instanceof SubscribableBuildAction)) {
        return;
    }
    GradleInternal gradle = buildController.getGradle();
    SubscribableBuildAction subscribableBuildAction = (SubscribableBuildAction) action;
    // register listeners that dispatch all progress via the registered BuildEventConsumer instance,
    // this allows to send progress events back to the DaemonClient (via short-cut)
    registerListenersForClientSubscriptions(subscribableBuildAction.getClientSubscriptions(), gradle);
    try {
        delegate.run(action, buildController);
    } finally {
        for (BuildOperationListener listener : listeners) {
            buildOperationService.removeListener(listener);
        }
    }
}
Also used : GradleInternal(org.gradle.api.internal.GradleInternal) BuildOperationListener(org.gradle.internal.progress.BuildOperationListener) SubscribableBuildAction(org.gradle.tooling.internal.provider.SubscribableBuildAction)

Aggregations

BuildOperationListener (org.gradle.internal.progress.BuildOperationListener)2 GradleInternal (org.gradle.api.internal.GradleInternal)1 BuildEventConsumer (org.gradle.initialization.BuildEventConsumer)1 SubscribableBuildAction (org.gradle.tooling.internal.provider.SubscribableBuildAction)1