use of org.gradle.internal.execution.UnitOfWork.Identity in project gradle by gradle.
the class IdentityCacheStep method executeDeferred.
@Override
public <T, O> T executeDeferred(UnitOfWork work, C context, Cache<Identity, Try<O>> cache, DeferredExecutionHandler<O, T> handler) {
Identity identity = context.getIdentity();
Try<O> cachedOutput = cache.getIfPresent(identity);
if (cachedOutput != null) {
return handler.processCachedOutput(cachedOutput);
} else {
return handler.processDeferredOutput(() -> cache.get(identity, () -> execute(work, context).getExecutionResult().map(ExecutionResult::getOutput).map(Cast::<O>uncheckedNonnullCast)));
}
}
use of org.gradle.internal.execution.UnitOfWork.Identity in project gradle by gradle.
the class IdentifyStep method createIdentityContext.
@Nonnull
private IdentityContext createIdentityContext(UnitOfWork work, C context) {
InputFingerprinter.Result inputs = work.getInputFingerprinter().fingerprintInputProperties(ImmutableSortedMap.of(), ImmutableSortedMap.of(), ImmutableSortedMap.of(), ImmutableSortedMap.of(), work::visitIdentityInputs);
ImmutableSortedMap<String, ValueSnapshot> identityInputProperties = inputs.getValueSnapshots();
ImmutableSortedMap<String, CurrentFileCollectionFingerprint> identityInputFileProperties = inputs.getFileFingerprints();
Identity identity = work.identify(identityInputProperties, identityInputFileProperties);
return new IdentityContext() {
@Override
public Optional<String> getNonIncrementalReason() {
return context.getNonIncrementalReason();
}
@Override
public WorkValidationContext getValidationContext() {
return context.getValidationContext();
}
@Override
public ImmutableSortedMap<String, ValueSnapshot> getInputProperties() {
return identityInputProperties;
}
@Override
public ImmutableSortedMap<String, CurrentFileCollectionFingerprint> getInputFileProperties() {
return identityInputFileProperties;
}
@Override
public Identity getIdentity() {
return identity;
}
};
}
use of org.gradle.internal.execution.UnitOfWork.Identity in project gradle by gradle.
the class LoadPreviousExecutionStateStep method execute.
@Override
public R execute(UnitOfWork work, C context) {
Identity identity = context.getIdentity();
Optional<PreviousExecutionState> previousExecutionState = context.getHistory().flatMap(history -> history.load(identity.getUniqueId()));
return delegate.execute(work, new PreviousExecutionContext() {
@Override
public Optional<PreviousExecutionState> getPreviousExecutionState() {
return previousExecutionState;
}
@Override
public Optional<String> getNonIncrementalReason() {
return context.getNonIncrementalReason();
}
@Override
public WorkValidationContext getValidationContext() {
return context.getValidationContext();
}
@Override
public ImmutableSortedMap<String, ValueSnapshot> getInputProperties() {
return context.getInputProperties();
}
@Override
public ImmutableSortedMap<String, CurrentFileCollectionFingerprint> getInputFileProperties() {
return context.getInputFileProperties();
}
@Override
public Identity getIdentity() {
return context.getIdentity();
}
@Override
public File getWorkspace() {
return context.getWorkspace();
}
@Override
public Optional<ExecutionHistoryStore> getHistory() {
return context.getHistory();
}
});
}
Aggregations