use of org.gradle.internal.snapshot.FileSystemSnapshot 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));
}
use of org.gradle.internal.snapshot.FileSystemSnapshot in project gradle by gradle.
the class TarBuildCacheEntryPacker method pack.
private long pack(CacheableEntity entity, Map<String, ? extends FileSystemSnapshot> snapshots, TarArchiveOutputStream tarOutput) {
AtomicLong entries = new AtomicLong();
entity.visitOutputTrees((treeName, type, root) -> {
FileSystemSnapshot treeSnapshots = snapshots.get(treeName);
try {
long entryCount = packTree(treeName, type, treeSnapshots, tarOutput);
entries.addAndGet(entryCount);
} catch (Exception ex) {
throw new RuntimeException(String.format("Could not pack tree '%s': %s", treeName, ex.getMessage()), ex);
}
});
return entries.get();
}
Aggregations