Search in sources :

Example 1 with KnownImplementationSnapshot

use of org.gradle.internal.snapshot.impl.KnownImplementationSnapshot in project gradle by gradle.

the class DefaultExecutionStateChangeDetector method detectChanges.

@Override
public ExecutionStateChanges detectChanges(Describable executable, PreviousExecutionState lastExecution, BeforeExecutionState thisExecution, IncrementalInputProperties incrementalInputProperties) {
    // Capture changes in execution outcome
    ChangeContainer previousSuccessState = new PreviousSuccessChanges(lastExecution.isSuccessful());
    // Capture changes to implementation
    // After validation, the current implementations can't be unknown when detecting changes.
    // Previous implementations can still be unknown, since we store the inputs in the task history even if validation fails.
    // When we fail the build for unknown implementations, then the previous implementations also can't be unknown.
    KnownImplementationSnapshot currentImplementation = Cast.uncheckedNonnullCast(thisExecution.getImplementation());
    ImmutableList<KnownImplementationSnapshot> currentAdditionalImplementations = Cast.uncheckedNonnullCast(thisExecution.getAdditionalImplementations());
    ChangeContainer implementationChanges = new ImplementationChanges(lastExecution.getImplementation(), lastExecution.getAdditionalImplementations(), currentImplementation, currentAdditionalImplementations, executable);
    // Capture non-file input changes
    ChangeContainer inputPropertyChanges = new PropertyChanges(lastExecution.getInputProperties().keySet(), thisExecution.getInputProperties().keySet(), "Input", executable);
    ChangeContainer inputPropertyValueChanges = new InputValueChanges(lastExecution.getInputProperties(), thisExecution.getInputProperties(), executable);
    // Capture input files state
    ChangeContainer inputFilePropertyChanges = new PropertyChanges(lastExecution.getInputFileProperties().keySet(), thisExecution.getInputFileProperties().keySet(), "Input file", executable);
    InputFileChanges nonIncrementalInputFileChanges = incrementalInputProperties.nonIncrementalChanges(lastExecution.getInputFileProperties(), thisExecution.getInputFileProperties());
    // Capture output files state
    ChangeContainer outputFilePropertyChanges = new PropertyChanges(lastExecution.getOutputFilesProducedByWork().keySet(), thisExecution.getOutputFileLocationSnapshots().keySet(), "Output", executable);
    ImmutableSortedMap<String, FileSystemSnapshot> remainingPreviouslyProducedOutputs = thisExecution.getDetectedOverlappingOutputs().isPresent() ? findOutputsStillPresentSincePreviousExecution(lastExecution.getOutputFilesProducedByWork(), thisExecution.getOutputFileLocationSnapshots()) : thisExecution.getOutputFileLocationSnapshots();
    OutputFileChanges outputFileChanges = new OutputFileChanges(lastExecution.getOutputFilesProducedByWork(), remainingPreviouslyProducedOutputs);
    // Collect changes that would trigger a rebuild
    ChangeContainer rebuildTriggeringChanges = errorHandling(executable, new SummarizingChangeContainer(previousSuccessState, implementationChanges, inputPropertyChanges, inputPropertyValueChanges, outputFilePropertyChanges, outputFileChanges, inputFilePropertyChanges, nonIncrementalInputFileChanges));
    ImmutableList<String> rebuildReasons = collectChanges(rebuildTriggeringChanges);
    if (!rebuildReasons.isEmpty()) {
        return ExecutionStateChanges.nonIncremental(rebuildReasons, thisExecution, incrementalInputProperties);
    } else {
        // Collect incremental input changes
        InputFileChanges directIncrementalInputFileChanges = incrementalInputProperties.incrementalChanges(lastExecution.getInputFileProperties(), thisExecution.getInputFileProperties());
        InputFileChanges incrementalInputFileChanges = errorHandling(executable, caching(directIncrementalInputFileChanges));
        ImmutableList<String> incrementalInputFileChangeMessages = collectChanges(incrementalInputFileChanges);
        return ExecutionStateChanges.incremental(incrementalInputFileChangeMessages, thisExecution, incrementalInputFileChanges, incrementalInputProperties);
    }
}
Also used : FileSystemSnapshot(org.gradle.internal.snapshot.FileSystemSnapshot) KnownImplementationSnapshot(org.gradle.internal.snapshot.impl.KnownImplementationSnapshot)

Aggregations

FileSystemSnapshot (org.gradle.internal.snapshot.FileSystemSnapshot)1 KnownImplementationSnapshot (org.gradle.internal.snapshot.impl.KnownImplementationSnapshot)1