Search in sources :

Example 1 with AbstractTaskResult

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

the class TaskOperationMapper method createFinishedEvent.

@Override
public InternalOperationFinishedProgressEvent createFinishedEvent(DefaultTaskDescriptor descriptor, ExecuteTaskBuildOperationDetails details, OperationFinishEvent finishEvent) {
    TaskInternal task = details.getTask();
    AbstractTaskResult taskResult = operationResultPostProcessor.process(toTaskResult(task, finishEvent), descriptor.getId());
    return new DefaultTaskFinishedProgressEvent(finishEvent.getEndTime(), descriptor, taskResult);
}
Also used : DefaultTaskFinishedProgressEvent(org.gradle.internal.build.event.types.DefaultTaskFinishedProgressEvent) TaskInternal(org.gradle.api.internal.TaskInternal) AbstractTaskResult(org.gradle.internal.build.event.types.AbstractTaskResult)

Example 2 with AbstractTaskResult

use of org.gradle.internal.build.event.types.AbstractTaskResult 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

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