use of org.gradle.internal.execution.UnitOfWork in project gradle by gradle.
the class ResolveChangesStep method createIncrementalInputProperties.
private static IncrementalInputProperties createIncrementalInputProperties(UnitOfWork work) {
UnitOfWork.InputChangeTrackingStrategy inputChangeTrackingStrategy = work.getInputChangeTrackingStrategy();
switch(inputChangeTrackingStrategy) {
case NONE:
return IncrementalInputProperties.NONE;
// noinspection deprecation
case ALL_PARAMETERS:
// When using IncrementalTaskInputs, keep the old behaviour of all file inputs being incremental
return IncrementalInputProperties.ALL;
case INCREMENTAL_PARAMETERS:
ImmutableBiMap.Builder<String, Object> builder = ImmutableBiMap.builder();
InputVisitor visitor = new InputVisitor() {
@Override
public void visitInputFileProperty(String propertyName, InputPropertyType type, FileValueSupplier valueSupplier) {
if (type.isIncremental()) {
Object value = valueSupplier.getValue();
if (value == null) {
throw new InvalidUserDataException("Must specify a value for incremental input property '" + propertyName + "'.");
}
builder.put(propertyName, value);
}
}
};
work.visitIdentityInputs(visitor);
work.visitRegularInputs(visitor);
return new DefaultIncrementalInputProperties(builder.build());
default:
throw new AssertionError("Unknown InputChangeTrackingStrategy: " + inputChangeTrackingStrategy);
}
}
use of org.gradle.internal.execution.UnitOfWork 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));
}
Aggregations