use of org.gradle.api.internal.tasks.TaskStateInternal in project gradle by gradle.
the class DefaultTaskGraphExecuterTest method createTask.
private TaskInternal createTask(final String name) {
TaskInternal task = context.mock(TaskInternal.class);
TaskStateInternal state = context.mock(TaskStateInternal.class);
final TaskOutputs outputs = context.mock(DefaultTaskOutputs.class);
setExpectations(name, task, state, outputs);
return task;
}
use of org.gradle.api.internal.tasks.TaskStateInternal in project gradle by gradle.
the class DefaultTaskGraphExecuterTest method task.
private Task task(final String name, final Task... dependsOn) {
final TaskInternal task = context.mock(TaskInternal.class);
final TaskStateInternal state = context.mock(TaskStateInternal.class);
final TaskOutputs outputs = context.mock(DefaultTaskOutputs.class);
setExpectations(name, task, state, outputs);
dependsOn(task, dependsOn);
context.checking(new Expectations() {
{
atMost(1).of(executer).execute(with(sameInstance(task)), with(sameInstance(state)), with(notNullValue(TaskExecutionContext.class)));
will(new ExecuteTaskAction(task));
allowing(state).getFailure();
will(returnValue(null));
}
});
return task;
}
use of org.gradle.api.internal.tasks.TaskStateInternal in project gradle by gradle.
the class DefaultTaskGraphExecuterTest method brokenTask.
private Task brokenTask(String name, final RuntimeException failure, final Task... dependsOn) {
final TaskInternal task = context.mock(TaskInternal.class);
final TaskStateInternal state = context.mock(TaskStateInternal.class);
final TaskOutputs outputs = context.mock(DefaultTaskOutputs.class);
setExpectations(name, task, state, outputs);
dependsOn(task, dependsOn);
context.checking(new Expectations() {
{
atMost(1).of(executer).execute(with(sameInstance(task)), with(sameInstance(state)), with(notNullValue(TaskExecutionContext.class)));
will(new ExecuteTaskAction(task));
allowing(state).getFailure();
will(returnValue(failure));
allowing(state).rethrowFailure();
will(throwException(failure));
}
});
return task;
}
use of org.gradle.api.internal.tasks.TaskStateInternal in project gradle by gradle.
the class TaskExecutionStatisticsEventAdapter method afterExecute.
@Override
public void afterExecute(Task task, TaskState state) {
TaskStateInternal stateInternal = (TaskStateInternal) state;
TaskExecutionOutcome outcome = stateInternal.getOutcome();
taskCounts.put(outcome, taskCounts.get(outcome) + 1);
if (outcome == TaskExecutionOutcome.EXECUTED && stateInternal.getTaskOutputCaching().isEnabled()) {
cacheMissCount++;
}
}
use of org.gradle.api.internal.tasks.TaskStateInternal in project gradle by gradle.
the class ClientForwardingTaskOperationListener method toTaskResult.
private static AbstractTaskResult toTaskResult(TaskInternal task, OperationResult 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)));
}
}
}
Aggregations