use of org.gradle.internal.execution.history.impl.DefaultAfterExecutionState 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.history.impl.DefaultAfterExecutionState in project gradle by gradle.
the class CaptureStateAfterExecutionStep method captureStateAfterExecution.
private Optional<AfterExecutionState> captureStateAfterExecution(UnitOfWork work, BeforeExecutionContext context, BeforeExecutionState beforeExecutionState, Duration duration) {
return operation(operationContext -> {
try {
Timer timer = Time.startTimer();
ImmutableSortedMap<String, FileSystemSnapshot> outputsProducedByWork = captureOutputs(work, context, beforeExecutionState);
long snapshotOutputDuration = timer.getElapsedMillis();
// The origin execution time is recorded as “work duration” + “output snapshotting duration”,
// As this is _roughly_ the amount of time that is avoided by reusing the outputs,
// which is currently the _only_ thing this value is used for.
Duration originExecutionTime = duration.plus(Duration.ofMillis(snapshotOutputDuration));
OriginMetadata originMetadata = new OriginMetadata(buildInvocationScopeId.asString(), originExecutionTime);
AfterExecutionState afterExecutionState = new DefaultAfterExecutionState(beforeExecutionState, outputsProducedByWork, originMetadata, false);
operationContext.setResult(Operation.Result.INSTANCE);
return Optional.of(afterExecutionState);
} catch (OutputSnapshotter.OutputFileSnapshottingException e) {
work.handleUnreadableOutputs(e);
operationContext.setResult(Operation.Result.INSTANCE);
return Optional.empty();
}
}, BuildOperationDescriptor.displayName("Snapshot outputs after executing " + work.getDisplayName()).details(Operation.Details.INSTANCE));
}
Aggregations