Search in sources :

Example 1 with Identity

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)));
    }
}
Also used : Cast(org.gradle.internal.Cast) Identity(org.gradle.internal.execution.UnitOfWork.Identity)

Example 2 with Identity

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;
        }
    };
}
Also used : ValueSnapshot(org.gradle.internal.snapshot.ValueSnapshot) InputFingerprinter(org.gradle.internal.execution.fingerprint.InputFingerprinter) CurrentFileCollectionFingerprint(org.gradle.internal.fingerprint.CurrentFileCollectionFingerprint) Identity(org.gradle.internal.execution.UnitOfWork.Identity) Nonnull(javax.annotation.Nonnull)

Example 3 with 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();
        }
    });
}
Also used : Optional(java.util.Optional) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) PreviousExecutionState(org.gradle.internal.execution.history.PreviousExecutionState) Identity(org.gradle.internal.execution.UnitOfWork.Identity) File(java.io.File) WorkValidationContext(org.gradle.internal.execution.WorkValidationContext)

Aggregations

Identity (org.gradle.internal.execution.UnitOfWork.Identity)3 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 File (java.io.File)1 Optional (java.util.Optional)1 Nonnull (javax.annotation.Nonnull)1 Cast (org.gradle.internal.Cast)1 WorkValidationContext (org.gradle.internal.execution.WorkValidationContext)1 InputFingerprinter (org.gradle.internal.execution.fingerprint.InputFingerprinter)1 PreviousExecutionState (org.gradle.internal.execution.history.PreviousExecutionState)1 CurrentFileCollectionFingerprint (org.gradle.internal.fingerprint.CurrentFileCollectionFingerprint)1 ValueSnapshot (org.gradle.internal.snapshot.ValueSnapshot)1