Search in sources :

Example 6 with SnapshotHierarchy

use of org.gradle.internal.snapshot.SnapshotHierarchy in project gradle by gradle.

the class WatchableHierarchies method updateUnwatchableFilesOnBuildStart.

@CheckReturnValue
private SnapshotHierarchy updateUnwatchableFilesOnBuildStart(SnapshotHierarchy root, Invalidator invalidator, List<File> unsupportedFileSystems) {
    SnapshotHierarchy newRoot = root;
    FileHierarchySet oldUnwatchableFiles = unwatchableFiles;
    unwatchableFiles = unsupportedFileSystems.stream().reduce(FileHierarchySet.empty(), FileHierarchySet::plus, nonCombining());
    if (!oldUnwatchableFiles.equals(unwatchableFiles)) {
        // Remove previously unwatchable files, since they may become watchable.
        // If we register a watchable hierarchy, then there mustn't be anything in the VFS at that location.
        newRoot = invalidateUnwatchableHierarchies(newRoot, invalidator, oldUnwatchableFiles);
        // Remove current unwatchable files, since they still may be watched.
        newRoot = invalidateUnwatchableHierarchies(newRoot, invalidator, unwatchableFiles);
        hierarchies.removeIf(unwatchableFiles::contains);
        watchableFiles = buildWatchableFilesFromHierarchies(hierarchies);
        // Replay the watchable hierarchies since the end of last build, since they have become watchable.
        for (File watchableHierarchy : watchableHierarchiesSinceLastBuildFinish) {
            if (!unwatchableFiles.contains(watchableHierarchy)) {
                doRegisterWatchableHierarchy(watchableHierarchy, newRoot);
            }
        }
    }
    return newRoot;
}
Also used : SnapshotHierarchy(org.gradle.internal.snapshot.SnapshotHierarchy) FileHierarchySet(org.gradle.internal.file.FileHierarchySet) File(java.io.File) CheckReturnValue(javax.annotation.CheckReturnValue)

Example 7 with SnapshotHierarchy

use of org.gradle.internal.snapshot.SnapshotHierarchy in project gradle by gradle.

the class VfsRootReference method update.

public void update(UnaryOperator<SnapshotHierarchy> updateFunction) {
    updateLock.lock();
    try {
        SnapshotHierarchy currentRoot = root;
        root = updateFunction.apply(currentRoot);
    } finally {
        updateLock.unlock();
    }
}
Also used : SnapshotHierarchy(org.gradle.internal.snapshot.SnapshotHierarchy)

Example 8 with SnapshotHierarchy

use of org.gradle.internal.snapshot.SnapshotHierarchy in project gradle by gradle.

the class AbstractVirtualFileSystem method invalidate.

@Override
public void invalidate(Iterable<String> locations) {
    LOGGER.debug("Invalidating VFS paths: {}", locations);
    rootReference.update(root -> {
        SnapshotHierarchy result = root;
        for (String location : locations) {
            SnapshotHierarchy currentRoot = result;
            result = updateNotifyingListeners(diffListener -> currentRoot.invalidate(location, diffListener));
        }
        return result;
    });
}
Also used : VirtualFileSystem(org.gradle.internal.vfs.VirtualFileSystem) Logger(org.slf4j.Logger) FileSystemLocationSnapshot(org.gradle.internal.snapshot.FileSystemLocationSnapshot) LoggerFactory(org.slf4j.LoggerFactory) MetadataSnapshot(org.gradle.internal.snapshot.MetadataSnapshot) Optional(java.util.Optional) SnapshotHierarchy(org.gradle.internal.snapshot.SnapshotHierarchy) SnapshotHierarchy(org.gradle.internal.snapshot.SnapshotHierarchy)

Example 9 with SnapshotHierarchy

use of org.gradle.internal.snapshot.SnapshotHierarchy in project gradle by gradle.

the class AbstractFileWatcherUpdater method invalidateMovedDirectoriesOnBuildStarted.

@CheckReturnValue
private SnapshotHierarchy invalidateMovedDirectoriesOnBuildStarted(SnapshotHierarchy root) {
    SnapshotHierarchy newRoot = root;
    WatchableHierarchies.Invalidator invalidator = createInvalidator();
    for (File movedDirectory : movedDirectoryHandler.stopWatchingMovedDirectories(root)) {
        LOGGER.info("Dropping VFS state for moved directory {}", movedDirectory.getAbsolutePath());
        newRoot = invalidator.invalidate(movedDirectory.getAbsolutePath(), newRoot);
    }
    return newRoot;
}
Also used : SnapshotHierarchy(org.gradle.internal.snapshot.SnapshotHierarchy) File(java.io.File) CheckReturnValue(javax.annotation.CheckReturnValue)

Example 10 with SnapshotHierarchy

use of org.gradle.internal.snapshot.SnapshotHierarchy in project gradle by gradle.

the class HierarchicalFileWatcherUpdater method updateVfsOnBuildFinished.

@Override
public SnapshotHierarchy updateVfsOnBuildFinished(SnapshotHierarchy root, WatchMode watchMode, int maximumNumberOfWatchedHierarchies, List<File> unsupportedFileSystems) {
    SnapshotHierarchy newRoot = super.updateVfsOnBuildFinished(root, watchMode, maximumNumberOfWatchedHierarchies, unsupportedFileSystems);
    LOGGER.info("Watched directory hierarchies: {}", watchedHierarchies);
    return newRoot;
}
Also used : SnapshotHierarchy(org.gradle.internal.snapshot.SnapshotHierarchy)

Aggregations

SnapshotHierarchy (org.gradle.internal.snapshot.SnapshotHierarchy)15 CheckReturnValue (javax.annotation.CheckReturnValue)8 File (java.io.File)6 NativeException (net.rubygrapefruit.platform.NativeException)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 FileHierarchySet (org.gradle.internal.file.FileHierarchySet)3 BuildOperationContext (org.gradle.internal.operations.BuildOperationContext)3 BuildOperationDescriptor (org.gradle.internal.operations.BuildOperationDescriptor)3 CallableBuildOperation (org.gradle.internal.operations.CallableBuildOperation)3 FileSystemLocationSnapshot (org.gradle.internal.snapshot.FileSystemLocationSnapshot)3 WatchingNotSupportedException (org.gradle.internal.watch.WatchingNotSupportedException)3 FileWatcherRegistry (org.gradle.internal.watch.registry.FileWatcherRegistry)3 FileSystemWatchingStatistics (org.gradle.internal.watch.vfs.FileSystemWatchingStatistics)3 IOException (java.io.IOException)2 Collection (java.util.Collection)2 List (java.util.List)2 Set (java.util.Set)2 Nullable (javax.annotation.Nullable)2 InotifyInstanceLimitTooLowException (net.rubygrapefruit.platform.internal.jni.InotifyInstanceLimitTooLowException)2