use of org.gradle.internal.execution.history.OverlappingOutputs in project gradle by gradle.
the class DefaultOverlappingOutputDetector method detect.
@Override
@Nullable
public OverlappingOutputs detect(ImmutableSortedMap<String, FileSystemSnapshot> previous, ImmutableSortedMap<String, FileSystemSnapshot> current) {
for (Map.Entry<String, FileSystemSnapshot> entry : current.entrySet()) {
String propertyName = entry.getKey();
FileSystemSnapshot currentSnapshot = entry.getValue();
FileSystemSnapshot previousSnapshot = previous.getOrDefault(propertyName, FileSystemSnapshot.EMPTY);
// If the root hashes are the same there are no overlapping outputs
if (getRootHashes(previousSnapshot).equals(getRootHashes(currentSnapshot))) {
continue;
}
OverlappingOutputs overlappingOutputs = detect(propertyName, previousSnapshot, currentSnapshot);
if (overlappingOutputs != null) {
return overlappingOutputs;
}
}
return null;
}
use of org.gradle.internal.execution.history.OverlappingOutputs in project gradle by gradle.
the class DefaultOverlappingOutputDetector method detect.
@Nullable
private static OverlappingOutputs detect(String propertyName, FileSystemSnapshot previous, FileSystemSnapshot before) {
Map<String, FileSystemLocationSnapshot> previousIndex = SnapshotUtil.index(previous);
OverlappingOutputsDetectingVisitor outputsDetectingVisitor = new OverlappingOutputsDetectingVisitor(previousIndex);
before.accept(outputsDetectingVisitor);
String overlappingPath = outputsDetectingVisitor.getOverlappingPath();
return overlappingPath == null ? null : new OverlappingOutputs(propertyName, overlappingPath);
}
use of org.gradle.internal.execution.history.OverlappingOutputs 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);
}
use of org.gradle.internal.execution.history.OverlappingOutputs in project gradle by gradle.
the class ResolveCachingStateStep method calculateCachingState.
private CachingState calculateCachingState(UnitOfWork work, BeforeExecutionState beforeExecutionState) {
Logger logger = buildCache.isEmitDebugLogging() ? LOGGER : NOPLogger.NOP_LOGGER;
CachingStateFactory cachingStateFactory = new DefaultCachingStateFactory(logger);
ImmutableList.Builder<CachingDisabledReason> cachingDisabledReasonsBuilder = ImmutableList.builder();
if (!buildCache.isEnabled()) {
cachingDisabledReasonsBuilder.add(BUILD_CACHE_DISABLED_REASON);
}
OverlappingOutputs detectedOverlappingOutputs = beforeExecutionState.getDetectedOverlappingOutputs().orElse(null);
work.shouldDisableCaching(detectedOverlappingOutputs).ifPresent(cachingDisabledReasonsBuilder::add);
return cachingStateFactory.createCachingState(beforeExecutionState, cachingDisabledReasonsBuilder.build());
}
Aggregations