use of org.gradle.internal.operations.BuildOperationRef in project gradle by gradle.
the class DefaultWorkerExecutor method submit.
private void submit(final ActionExecutionSpec spec, final IsolationMode isolationMode, final DaemonForkOptions daemonForkOptions) {
final WorkerLease currentWorkerWorkerLease = getCurrentWorkerLease();
final BuildOperationRef currentBuildOperation = buildOperationExecutor.getCurrentOperation();
ListenableFuture<DefaultWorkResult> workerDaemonResult = executor.submit(new Callable<DefaultWorkResult>() {
@Override
public DefaultWorkResult call() throws Exception {
try {
WorkerFactory workerFactory = getWorkerFactory(isolationMode);
Worker worker = workerFactory.getWorker(daemonForkOptions);
return worker.execute(spec, currentWorkerWorkerLease, currentBuildOperation);
} catch (Throwable t) {
throw new WorkExecutionException(spec.getDisplayName(), t);
}
}
});
registerAsyncWork(spec.getDisplayName(), workerDaemonResult);
}
use of org.gradle.internal.operations.BuildOperationRef in project gradle by gradle.
the class ExecuteActionsTaskExecuter method executeAction.
private void executeAction(final String actionDisplayName, final TaskInternal task, final ContextAwareTaskAction action, TaskExecutionContext context) {
action.contextualise(context);
buildOperationExecutor.run(new RunnableBuildOperation() {
@Override
public BuildOperationDescriptor.Builder description() {
return BuildOperationDescriptor.displayName(actionDisplayName + " for " + task.getPath()).name(actionDisplayName);
}
@Override
public void run(BuildOperationContext context) {
BuildOperationRef currentOperation = buildOperationExecutor.getCurrentOperation();
Throwable actionFailure = null;
try {
action.execute(task);
} catch (Throwable t) {
actionFailure = t;
} finally {
action.releaseContext();
}
try {
asyncWorkTracker.waitForCompletion(currentOperation, true);
} catch (Throwable t) {
List<Throwable> failures = Lists.newArrayList();
if (actionFailure != null) {
failures.add(actionFailure);
}
if (t instanceof MultiCauseException) {
failures.addAll(((MultiCauseException) t).getCauses());
} else {
failures.add(t);
}
if (failures.size() > 1) {
throw new MultipleTaskActionFailures("Multiple task action failures occurred:", failures);
} else {
throw UncheckedException.throwAsUncheckedException(failures.get(0));
}
}
if (actionFailure != null) {
throw UncheckedException.throwAsUncheckedException(actionFailure);
}
}
});
}
Aggregations