use of org.gradle.api.internal.tasks.TaskStateInternal in project gradle by gradle.
the class ClientForwardingTaskOperationListener method toTaskResult.
private static AbstractTaskResult toTaskResult(TaskInternal task, OperationFinishEvent result) {
TaskStateInternal state = task.getState();
long startTime = result.getStartTime();
long endTime = result.getEndTime();
if (state.getUpToDate()) {
return new DefaultTaskSuccessResult(startTime, endTime, true, state.isFromCache(), state.getSkipMessage());
} else if (state.getSkipped()) {
return new DefaultTaskSkippedResult(startTime, endTime, state.getSkipMessage());
} else {
Throwable failure = result.getFailure();
if (failure == null) {
return new DefaultTaskSuccessResult(startTime, endTime, false, state.isFromCache(), "SUCCESS");
} else {
return new DefaultTaskFailureResult(startTime, endTime, Collections.singletonList(DefaultFailure.fromThrowable(failure)));
}
}
}
use of org.gradle.api.internal.tasks.TaskStateInternal 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);
}
}
}
use of org.gradle.api.internal.tasks.TaskStateInternal in project gradle by gradle.
the class ExecuteActionsTaskExecuter method executeIfValid.
private TaskExecuterResult executeIfValid(TaskInternal task, TaskStateInternal state, TaskExecutionContext context, TaskExecution work) {
ExecutionEngine.Request request = executionEngine.createRequest(work);
context.getTaskExecutionMode().getRebuildReason().ifPresent(request::forceNonIncremental);
request.withValidationContext(context.getValidationContext());
Result result = request.execute();
result.getExecutionResult().ifSuccessfulOrElse(executionResult -> state.setOutcome(TaskExecutionOutcome.valueOf(executionResult.getOutcome())), failure -> state.setOutcome(new TaskExecutionException(task, failure)));
return new TaskExecuterResult() {
@Override
public Optional<OriginMetadata> getReusedOutputOriginMetadata() {
return result.getReusedOutputOriginMetadata();
}
@Override
public boolean executedIncrementally() {
return result.getExecutionResult().map(executionResult -> executionResult.getOutcome() == ExecutionOutcome.EXECUTED_INCREMENTALLY).getOrMapFailure(throwable -> false);
}
@Override
public List<String> getExecutionReasons() {
return result.getExecutionReasons();
}
@Override
public CachingState getCachingState() {
return result.getCachingState();
}
};
}
use of org.gradle.api.internal.tasks.TaskStateInternal in project gradle by gradle.
the class LocalTaskNodeExecutor method execute.
@Override
public boolean execute(Node node, NodeExecutionContext context) {
if (node instanceof LocalTaskNode) {
LocalTaskNode localTaskNode = (LocalTaskNode) node;
TaskInternal task = localTaskNode.getTask();
TaskStateInternal state = task.getState();
if (state.getExecuted()) {
// This should move earlier in task scheduling, so that a worker thread does not even bother trying to run this task
return true;
}
ExecutionNodeAccessHierarchies.InputNodeAccessHierarchy inputHierarchy = context.getService(ExecutionNodeAccessHierarchies.InputNodeAccessHierarchy.class);
TaskExecutionContext ctx = new DefaultTaskExecutionContext(localTaskNode, localTaskNode.getTaskProperties(), localTaskNode.getValidationContext(), (historyMaintained, typeValidationContext) -> detectMissingDependencies(localTaskNode, historyMaintained, inputHierarchy, typeValidationContext));
TaskExecuter taskExecuter = context.getService(TaskExecuter.class);
taskExecuter.execute(task, state, ctx);
localTaskNode.getPostAction().execute(task);
return true;
} else {
return false;
}
}
Aggregations