Search in sources :

Example 1 with DefaultTaskFailureResult

use of org.gradle.internal.build.event.types.DefaultTaskFailureResult in project gradle by gradle.

the class TaskOperationMapper method toTaskResult.

private static AbstractTaskResult toTaskResult(TaskInternal task, OperationFinishEvent finishEvent) {
    TaskStateInternal state = task.getState();
    long startTime = finishEvent.getStartTime();
    long endTime = finishEvent.getEndTime();
    ExecuteTaskBuildOperationType.Result result = (ExecuteTaskBuildOperationType.Result) finishEvent.getResult();
    boolean incremental = result != null && result.isIncremental();
    if (state.getUpToDate()) {
        return new DefaultTaskSuccessResult(startTime, endTime, true, state.isFromCache(), state.getSkipMessage(), incremental, Collections.emptyList());
    } else if (state.getSkipped()) {
        return new DefaultTaskSkippedResult(startTime, endTime, state.getSkipMessage(), incremental);
    } else {
        List<String> executionReasons = result != null ? result.getUpToDateMessages() : null;
        Throwable failure = finishEvent.getFailure();
        if (failure == null) {
            return new DefaultTaskSuccessResult(startTime, endTime, false, state.isFromCache(), "SUCCESS", incremental, executionReasons);
        } else {
            return new DefaultTaskFailureResult(startTime, endTime, singletonList(DefaultFailure.fromThrowable(failure)), incremental, executionReasons);
        }
    }
}
Also used : TaskStateInternal(org.gradle.api.internal.tasks.TaskStateInternal) DefaultTaskSuccessResult(org.gradle.internal.build.event.types.DefaultTaskSuccessResult) DefaultTaskSkippedResult(org.gradle.internal.build.event.types.DefaultTaskSkippedResult) DefaultTaskFailureResult(org.gradle.internal.build.event.types.DefaultTaskFailureResult) ExecuteTaskBuildOperationType(org.gradle.api.internal.tasks.execution.ExecuteTaskBuildOperationType) Collections.singletonList(java.util.Collections.singletonList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) DefaultTaskSkippedResult(org.gradle.internal.build.event.types.DefaultTaskSkippedResult) DefaultTaskSuccessResult(org.gradle.internal.build.event.types.DefaultTaskSuccessResult) DefaultTaskFailureResult(org.gradle.internal.build.event.types.DefaultTaskFailureResult) AbstractTaskResult(org.gradle.internal.build.event.types.AbstractTaskResult)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 TaskStateInternal (org.gradle.api.internal.tasks.TaskStateInternal)1 ExecuteTaskBuildOperationType (org.gradle.api.internal.tasks.execution.ExecuteTaskBuildOperationType)1 AbstractTaskResult (org.gradle.internal.build.event.types.AbstractTaskResult)1 DefaultTaskFailureResult (org.gradle.internal.build.event.types.DefaultTaskFailureResult)1 DefaultTaskSkippedResult (org.gradle.internal.build.event.types.DefaultTaskSkippedResult)1 DefaultTaskSuccessResult (org.gradle.internal.build.event.types.DefaultTaskSuccessResult)1