Search in sources :

Example 1 with StopActionException

use of org.gradle.api.tasks.StopActionException in project gradle by gradle.

the class TaskExecution method executeActions.

private void executeActions(TaskInternal task, @Nullable InputChangesInternal inputChanges) {
    boolean hasTaskListener = listenerManager.hasListeners(org.gradle.api.execution.TaskActionListener.class) || listenerManager.hasListeners(org.gradle.api.execution.TaskExecutionListener.class);
    Iterator<InputChangesAwareTaskAction> actions = new ArrayList<>(task.getTaskActions()).iterator();
    while (actions.hasNext()) {
        InputChangesAwareTaskAction action = actions.next();
        task.getState().setDidWork(true);
        task.getStandardOutputCapture().start();
        boolean hasMoreWork = hasTaskListener || actions.hasNext();
        try {
            executeAction(action.getDisplayName(), task, action, inputChanges, hasMoreWork);
        } catch (StopActionException e) {
            // Ignore
            LOGGER.debug("Action stopped by some action with message: {}", e.getMessage());
        } catch (StopExecutionException e) {
            LOGGER.info("Execution stopped by some action with message: {}", e.getMessage());
            break;
        } finally {
            task.getStandardOutputCapture().stop();
        }
    }
}
Also used : InputChangesAwareTaskAction(org.gradle.api.internal.tasks.InputChangesAwareTaskAction) StopExecutionException(org.gradle.api.tasks.StopExecutionException) StopActionException(org.gradle.api.tasks.StopActionException)

Example 2 with StopActionException

use of org.gradle.api.tasks.StopActionException in project gradle by gradle.

the class ExecuteActionsTaskExecuter method executeActions.

private GradleException executeActions(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    LOGGER.debug("Executing actions for {}.", task);
    final List<ContextAwareTaskAction> actions = new ArrayList<ContextAwareTaskAction>(task.getTaskActions());
    for (ContextAwareTaskAction action : actions) {
        state.setDidWork(true);
        task.getStandardOutputCapture().start();
        try {
            executeAction(action.getDisplayName(), task, action, context);
        } catch (StopActionException e) {
            // Ignore
            LOGGER.debug("Action stopped by some action with message: {}", e.getMessage());
        } catch (StopExecutionException e) {
            LOGGER.info("Execution stopped by some action with message: {}", e.getMessage());
            break;
        } catch (Throwable t) {
            return new TaskExecutionException(task, t);
        } finally {
            task.getStandardOutputCapture().stop();
        }
    }
    return null;
}
Also used : TaskExecutionException(org.gradle.api.tasks.TaskExecutionException) StopExecutionException(org.gradle.api.tasks.StopExecutionException) ContextAwareTaskAction(org.gradle.api.internal.tasks.ContextAwareTaskAction) StopActionException(org.gradle.api.tasks.StopActionException) ArrayList(java.util.ArrayList)

Aggregations

StopActionException (org.gradle.api.tasks.StopActionException)2 StopExecutionException (org.gradle.api.tasks.StopExecutionException)2 ArrayList (java.util.ArrayList)1 ContextAwareTaskAction (org.gradle.api.internal.tasks.ContextAwareTaskAction)1 InputChangesAwareTaskAction (org.gradle.api.internal.tasks.InputChangesAwareTaskAction)1 TaskExecutionException (org.gradle.api.tasks.TaskExecutionException)1