use of org.gradle.internal.exceptions.MultiCauseException 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