Search in sources :

Example 6 with UnitOfWork

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);
    }
}
Also used : UnitOfWork(org.gradle.internal.execution.UnitOfWork) ImmutableBiMap(com.google.common.collect.ImmutableBiMap) InputPropertyType(org.gradle.internal.execution.fingerprint.InputFingerprinter.InputPropertyType) InvalidUserDataException(org.gradle.api.InvalidUserDataException) DefaultIncrementalInputProperties(org.gradle.internal.execution.history.changes.DefaultIncrementalInputProperties) InputVisitor(org.gradle.internal.execution.fingerprint.InputFingerprinter.InputVisitor) FileValueSupplier(org.gradle.internal.execution.fingerprint.InputFingerprinter.FileValueSupplier)

Example 7 with UnitOfWork

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));
}
Also used : UnitOfWork(org.gradle.internal.execution.UnitOfWork) ExecutionOutcome(org.gradle.internal.execution.ExecutionOutcome) Timer(org.gradle.internal.time.Timer) InputChangesInternal(org.gradle.internal.execution.history.changes.InputChangesInternal) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) Duration(java.time.Duration) PreviousExecutionState(org.gradle.internal.execution.history.PreviousExecutionState)

Aggregations

UnitOfWork (org.gradle.internal.execution.UnitOfWork)7 File (java.io.File)4 ImmutableList (com.google.common.collect.ImmutableList)3 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)3 Duration (java.time.Duration)3 Optional (java.util.Optional)3 PreviousExecutionState (org.gradle.internal.execution.history.PreviousExecutionState)3 List (java.util.List)2 Map (java.util.Map)2 Try (org.gradle.internal.Try)2 WorkValidationContext (org.gradle.internal.execution.WorkValidationContext)2 CachingDisabledReason (org.gradle.internal.execution.caching.CachingDisabledReason)2 CachingDisabledReasonCategory (org.gradle.internal.execution.caching.CachingDisabledReasonCategory)2 BeforeExecutionState (org.gradle.internal.execution.history.BeforeExecutionState)2 ExecutionHistoryStore (org.gradle.internal.execution.history.ExecutionHistoryStore)2 CurrentFileCollectionFingerprint (org.gradle.internal.fingerprint.CurrentFileCollectionFingerprint)2 TypeValidationContext (org.gradle.internal.reflect.validation.TypeValidationContext)2 ValueSnapshot (org.gradle.internal.snapshot.ValueSnapshot)2 ImplementationSnapshot (org.gradle.internal.snapshot.impl.ImplementationSnapshot)2 Logger (org.slf4j.Logger)2