use of org.gradle.internal.watch.vfs.WatchLogging in project gradle by gradle.
the class FileSystemWatchingBuildActionRunner method run.
@Override
public Result run(BuildAction action, BuildTreeLifecycleController buildController) {
StartParameterInternal startParameter = action.getStartParameter();
WatchMode watchFileSystemMode = startParameter.getWatchFileSystemMode();
VfsLogging verboseVfsLogging = startParameter.isVfsVerboseLogging() ? VfsLogging.VERBOSE : VfsLogging.NORMAL;
WatchLogging debugWatchLogging = startParameter.isWatchFileSystemDebugLogging() ? WatchLogging.DEBUG : WatchLogging.NORMAL;
LOGGER.info("Watching the file system is configured to be {}", watchFileSystemMode.getDescription());
boolean continuousBuild = startParameter.isContinuous() || !deploymentRegistry.getRunningDeployments().isEmpty();
if (continuousBuild && watchFileSystemMode == WatchMode.DEFAULT) {
// Try to watch as much as possible when using continuous build.
watchFileSystemMode = WatchMode.ENABLED;
}
if (watchFileSystemMode.isEnabled()) {
dropVirtualFileSystemIfRequested(startParameter, virtualFileSystem);
}
if (verboseVfsLogging == VfsLogging.VERBOSE) {
logVfsStatistics("since last build", statStatisticsCollector, fileHasherStatisticsCollector, directorySnapshotterStatisticsCollector);
}
if (action.getStartParameter().getProjectCacheDir() != null) {
// See https://github.com/gradle/gradle/issues/17262
switch(watchFileSystemMode) {
case ENABLED:
throw new IllegalStateException("Enabling file system watching via --watch-fs (or via the " + StartParameterBuildOptions.WatchFileSystemOption.GRADLE_PROPERTY + " property) with --project-cache-dir also specified is not supported; remove either option to fix this problem");
case DEFAULT:
LOGGER.info("File system watching is disabled because --project-cache-dir is specified");
watchFileSystemMode = WatchMode.DISABLED;
break;
default:
break;
}
}
LOGGER.debug("Watching the file system computed to be {}", watchFileSystemMode.getDescription());
boolean actuallyWatching = virtualFileSystem.afterBuildStarted(watchFileSystemMode, verboseVfsLogging, debugWatchLogging, buildOperationRunner);
LOGGER.info("File system watching is {}", actuallyWatching ? "active" : "inactive");
// noinspection Convert2Lambda
eventEmitter.emitNowForCurrent(new FileSystemWatchingSettingsFinalizedProgressDetails() {
@Override
public boolean isEnabled() {
return actuallyWatching;
}
});
if (continuousBuild) {
if (!actuallyWatching) {
throw new IllegalStateException("Continuous build does not work when file system watching is disabled");
}
}
try {
return delegate.run(action, buildController);
} finally {
int maximumNumberOfWatchedHierarchies = VirtualFileSystemServices.getMaximumNumberOfWatchedHierarchies(startParameter);
virtualFileSystem.beforeBuildFinished(watchFileSystemMode, verboseVfsLogging, debugWatchLogging, buildOperationRunner, maximumNumberOfWatchedHierarchies);
if (verboseVfsLogging == VfsLogging.VERBOSE) {
logVfsStatistics("during current build", statStatisticsCollector, fileHasherStatisticsCollector, directorySnapshotterStatisticsCollector);
}
}
}
Aggregations