use of org.gradle.api.internal.tasks.TaskExecutionContext 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.TaskExecutionContext 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