use of org.gradle.internal.execution.ExecutionOutcome in project gradle by gradle.
the class SkipUpToDateStep method skipExecution.
private UpToDateResult skipExecution(UnitOfWork work, BeforeExecutionState beforeExecutionState, C context) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Skipping {} as it is up-to-date.", work.getDisplayName());
}
@SuppressWarnings("OptionalGetWithoutIsPresent") PreviousExecutionState previousExecutionState = context.getPreviousExecutionState().get();
AfterExecutionState afterExecutionState = new DefaultAfterExecutionState(beforeExecutionState, previousExecutionState.getOutputFilesProducedByWork(), previousExecutionState.getOriginMetadata(), true);
return new UpToDateResult() {
@Override
public ImmutableList<String> getExecutionReasons() {
return ImmutableList.of();
}
@Override
public Optional<AfterExecutionState> getAfterExecutionState() {
return Optional.of(afterExecutionState);
}
@Override
public Optional<OriginMetadata> getReusedOutputOriginMetadata() {
return Optional.of(previousExecutionState.getOriginMetadata());
}
@Override
public Try<ExecutionResult> getExecutionResult() {
return Try.successful(new ExecutionResult() {
@Override
public ExecutionOutcome getOutcome() {
return ExecutionOutcome.UP_TO_DATE;
}
@Override
public Object getOutput() {
return work.loadRestoredOutput(context.getWorkspace());
}
});
}
@Override
public Duration getDuration() {
return previousExecutionState.getOriginMetadata().getExecutionTime();
}
};
}
use of org.gradle.internal.execution.ExecutionOutcome in project gradle by gradle.
the class SkipEmptyWorkStep method skipExecutionWithEmptySources.
@Nonnull
private CachingResult skipExecutionWithEmptySources(UnitOfWork work, PreviousExecutionContext context) {
ImmutableSortedMap<String, FileSystemSnapshot> outputFilesAfterPreviousExecution = context.getPreviousExecutionState().map(PreviousExecutionState::getOutputFilesProducedByWork).orElse(ImmutableSortedMap.of());
ExecutionOutcome skipOutcome;
Timer timer = Time.startTimer();
if (outputFilesAfterPreviousExecution.isEmpty()) {
LOGGER.info("Skipping {} as it has no source files and no previous output files.", work.getDisplayName());
skipOutcome = ExecutionOutcome.SHORT_CIRCUITED;
} else {
boolean didWork = cleanPreviousTaskOutputs(outputFilesAfterPreviousExecution);
if (didWork) {
LOGGER.info("Cleaned previous output of {} as it has no source files.", work.getDisplayName());
skipOutcome = ExecutionOutcome.EXECUTED_NON_INCREMENTALLY;
} else {
skipOutcome = ExecutionOutcome.SHORT_CIRCUITED;
}
}
Duration duration = skipOutcome == ExecutionOutcome.SHORT_CIRCUITED ? Duration.ZERO : Duration.ofMillis(timer.getElapsedMillis());
broadcastWorkInputs(work, true);
return new CachingResult() {
@Override
public Duration getDuration() {
return duration;
}
@Override
public Try<ExecutionResult> getExecutionResult() {
return Try.successful(new ExecutionResult() {
@Override
public ExecutionOutcome getOutcome() {
return skipOutcome;
}
@Override
public Object getOutput() {
return work.loadRestoredOutput(context.getWorkspace());
}
});
}
@Override
public CachingState getCachingState() {
return CachingState.NOT_DETERMINED;
}
@Override
public ImmutableList<String> getExecutionReasons() {
return ImmutableList.of();
}
@Override
public Optional<AfterExecutionState> getAfterExecutionState() {
return Optional.empty();
}
@Override
public Optional<OriginMetadata> getReusedOutputOriginMetadata() {
return Optional.empty();
}
};
}
use of org.gradle.internal.execution.ExecutionOutcome in project gradle by gradle.
the class ExecuteStep method executeInternal.
private static Result executeInternal(UnitOfWork work, InputChangesContext context) {
UnitOfWork.ExecutionRequest executionRequest = new UnitOfWork.ExecutionRequest() {
@Override
public File getWorkspace() {
return context.getWorkspace();
}
@Override
public Optional<InputChangesInternal> getInputChanges() {
return context.getInputChanges();
}
@Override
public Optional<ImmutableSortedMap<String, FileSystemSnapshot>> getPreviouslyProducedOutputs() {
return context.getPreviousExecutionState().map(PreviousExecutionState::getOutputFilesProducedByWork);
}
};
UnitOfWork.WorkOutput workOutput;
Timer timer = Time.startTimer();
try {
workOutput = work.execute(executionRequest);
} catch (Throwable t) {
return ResultImpl.failed(t, Duration.ofMillis(timer.getElapsedMillis()));
}
Duration duration = Duration.ofMillis(timer.getElapsedMillis());
ExecutionOutcome outcome = determineOutcome(context, workOutput);
return ResultImpl.success(duration, new ExecutionResultImpl(outcome, workOutput));
}
use of org.gradle.internal.execution.ExecutionOutcome in project gradle by gradle.
the class ExecuteStep method determineOutcome.
private static ExecutionOutcome determineOutcome(InputChangesContext context, UnitOfWork.WorkOutput workOutput) {
ExecutionOutcome outcome;
switch(workOutput.getDidWork()) {
case DID_NO_WORK:
outcome = ExecutionOutcome.UP_TO_DATE;
break;
case DID_WORK:
boolean incremental = context.getInputChanges().map(InputChanges::isIncremental).orElse(false);
outcome = incremental ? ExecutionOutcome.EXECUTED_INCREMENTALLY : ExecutionOutcome.EXECUTED_NON_INCREMENTALLY;
break;
default:
throw new AssertionError();
}
return outcome;
}
Aggregations