Search in sources :

Example 1 with DefaultBeforeExecutionState

use of org.gradle.internal.execution.history.impl.DefaultBeforeExecutionState in project gradle by gradle.

the class CaptureStateBeforeExecutionStep method captureExecutionStateWithOutputs.

private BeforeExecutionState captureExecutionStateWithOutputs(UnitOfWork work, PreviousExecutionContext context, ImmutableSortedMap<String, FileSystemSnapshot> unfilteredOutputSnapshots) {
    Optional<PreviousExecutionState> previousExecutionState = context.getPreviousExecutionState();
    ImplementationsBuilder implementationsBuilder = new ImplementationsBuilder(classLoaderHierarchyHasher);
    work.visitImplementations(implementationsBuilder);
    ImplementationSnapshot implementation = implementationsBuilder.getImplementation();
    ImmutableList<ImplementationSnapshot> additionalImplementations = implementationsBuilder.getAdditionalImplementations();
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Implementation for {}: {}", work.getDisplayName(), implementation);
        LOGGER.debug("Additional implementations for {}: {}", work.getDisplayName(), additionalImplementations);
    }
    ImmutableSortedMap<String, ValueSnapshot> previousInputProperties = previousExecutionState.map(InputExecutionState::getInputProperties).orElse(ImmutableSortedMap.of());
    ImmutableSortedMap<String, ? extends FileCollectionFingerprint> previousInputFileFingerprints = previousExecutionState.map(InputExecutionState::getInputFileProperties).orElse(ImmutableSortedMap.of());
    ImmutableSortedMap<String, FileSystemSnapshot> previousOutputSnapshots = previousExecutionState.map(PreviousExecutionState::getOutputFilesProducedByWork).orElse(ImmutableSortedMap.of());
    OverlappingOutputs overlappingOutputs;
    switch(work.getOverlappingOutputHandling()) {
        case DETECT_OVERLAPS:
            overlappingOutputs = overlappingOutputDetector.detect(previousOutputSnapshots, unfilteredOutputSnapshots);
            break;
        case IGNORE_OVERLAPS:
            overlappingOutputs = null;
            break;
        default:
            throw new AssertionError();
    }
    InputFingerprinter.Result newInputs = work.getInputFingerprinter().fingerprintInputProperties(previousInputProperties, previousInputFileFingerprints, context.getInputProperties(), context.getInputFileProperties(), work::visitRegularInputs);
    return new DefaultBeforeExecutionState(implementation, additionalImplementations, newInputs.getAllValueSnapshots(), newInputs.getAllFileFingerprints(), unfilteredOutputSnapshots, overlappingOutputs);
}
Also used : ValueSnapshot(org.gradle.internal.snapshot.ValueSnapshot) DefaultBeforeExecutionState(org.gradle.internal.execution.history.impl.DefaultBeforeExecutionState) OverlappingOutputs(org.gradle.internal.execution.history.OverlappingOutputs) PreviousExecutionState(org.gradle.internal.execution.history.PreviousExecutionState) FileSystemSnapshot(org.gradle.internal.snapshot.FileSystemSnapshot) InputFingerprinter(org.gradle.internal.execution.fingerprint.InputFingerprinter) ImplementationSnapshot(org.gradle.internal.snapshot.impl.ImplementationSnapshot)

Aggregations

InputFingerprinter (org.gradle.internal.execution.fingerprint.InputFingerprinter)1 OverlappingOutputs (org.gradle.internal.execution.history.OverlappingOutputs)1 PreviousExecutionState (org.gradle.internal.execution.history.PreviousExecutionState)1 DefaultBeforeExecutionState (org.gradle.internal.execution.history.impl.DefaultBeforeExecutionState)1 FileSystemSnapshot (org.gradle.internal.snapshot.FileSystemSnapshot)1 ValueSnapshot (org.gradle.internal.snapshot.ValueSnapshot)1 ImplementationSnapshot (org.gradle.internal.snapshot.impl.ImplementationSnapshot)1