Skip to content

Commit

Permalink
Merge pull request gradle#15854 from gradle/lptr/vfs/remove-deprecate…
Browse files Browse the repository at this point in the history
…d-properties

Remove deprecated VFS flags
  • Loading branch information
lptr authored Jan 21, 2021
2 parents 4b49787 + 9c18839 commit 363d057
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@
import org.gradle.initialization.layout.ProjectCacheDir;
import org.gradle.internal.build.BuildAddedListener;
import org.gradle.internal.classloader.ClasspathHasher;
import org.gradle.internal.deprecation.DeprecationLogger;
import org.gradle.internal.event.ListenerManager;
import org.gradle.internal.execution.DefaultOutputSnapshotter;
import org.gradle.internal.execution.OutputChangeListener;
import org.gradle.internal.execution.OutputSnapshotter;
import org.gradle.internal.file.Stat;
import org.gradle.internal.fingerprint.DirectorySensitivity;
import org.gradle.internal.fingerprint.FileCollectionFingerprinter;
import org.gradle.internal.fingerprint.FileCollectionFingerprinterRegistry;
import org.gradle.internal.fingerprint.FileCollectionSnapshotter;
Expand All @@ -69,7 +69,6 @@
import org.gradle.internal.fingerprint.impl.DefaultFileCollectionFingerprinterRegistry;
import org.gradle.internal.fingerprint.impl.DefaultFileCollectionSnapshotter;
import org.gradle.internal.fingerprint.impl.DefaultGenericFileTreeSnapshotter;
import org.gradle.internal.fingerprint.DirectorySensitivity;
import org.gradle.internal.fingerprint.impl.IgnoredPathFileCollectionFingerprinter;
import org.gradle.internal.fingerprint.impl.NameOnlyFileCollectionFingerprinter;
import org.gradle.internal.fingerprint.impl.RelativePathFileCollectionFingerprinter;
Expand Down Expand Up @@ -114,46 +113,21 @@ public class VirtualFileSystemServices extends AbstractPluginServiceRegistry {

private static final Logger LOGGER = LoggerFactory.getLogger(VirtualFileSystemServices.class);

/**
* Deprecated system property used to enable watching the file system.
*
* Using this property causes Gradle to emit a deprecation warning.
*/
@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated
public static final String DEPRECATED_VFS_RETENTION_ENABLED_PROPERTY = "org.gradle.unsafe.vfs.retention";

/**
* When file system watching is enabled, this system property can be used to invalidate the entire VFS.
*
* @see org.gradle.initialization.StartParameterBuildOptions.WatchFileSystemOption
*/
public static final String VFS_DROP_PROPERTY = "org.gradle.vfs.drop";

/**
* Previous name for {@link #VFS_DROP_PROPERTY}.
*/
@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated
@VisibleForTesting
public static final String DEPRECATED_VFS_DROP_PROPERTY = "org.gradle.unsafe.vfs.drop";

public static final String MAX_HIERARCHIES_TO_WATCH_PROPERTY = "org.gradle.vfs.watch.hierarchies.max";

private static final int DEFAULT_MAX_HIERARCHIES_TO_WATCH = 50;
private static final int FILE_HASHER_MEMORY_CACHE_SIZE = 400000;

public static boolean isDropVfs(StartParameter startParameter) {
if (getSystemProperty(DEPRECATED_VFS_DROP_PROPERTY, startParameter.getSystemPropertiesArgs()) != null) {
DeprecationLogger
.deprecateSystemProperty(DEPRECATED_VFS_DROP_PROPERTY)
.replaceWith(VFS_DROP_PROPERTY)
.willBeRemovedInGradle7()
.undocumented()
.nagUser();
return isSystemPropertyEnabled(DEPRECATED_VFS_DROP_PROPERTY, startParameter.getSystemPropertiesArgs());
}
return isSystemPropertyEnabled(VFS_DROP_PROPERTY, startParameter.getSystemPropertiesArgs());
String dropVfs = getSystemProperty(VFS_DROP_PROPERTY, startParameter.getSystemPropertiesArgs());
return dropVfs != null && !"false".equalsIgnoreCase(dropVfs);
}

public static int getMaximumNumberOfWatchedHierarchies(StartParameter startParameter) {
Expand All @@ -163,15 +137,6 @@ public static int getMaximumNumberOfWatchedHierarchies(StartParameter startParam
: DEFAULT_MAX_HIERARCHIES_TO_WATCH;
}

public static boolean isDeprecatedVfsRetentionPropertyPresent(StartParameter startParameter) {
return getSystemProperty(DEPRECATED_VFS_RETENTION_ENABLED_PROPERTY, startParameter.getSystemPropertiesArgs()) != null;
}

private static boolean isSystemPropertyEnabled(String systemProperty, Map<String, String> systemPropertiesArgs) {
String value = getSystemProperty(systemProperty, systemPropertiesArgs);
return value != null && !"false".equalsIgnoreCase(value);
}

@Nullable
private static String getSystemProperty(String systemProperty, Map<String, String> systemPropertiesArgs) {
return systemPropertiesArgs.getOrDefault(systemProperty, System.getProperty(systemProperty));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.gradle.internal.watch

import org.gradle.initialization.StartParameterBuildOptions
import org.gradle.internal.service.scopes.VirtualFileSystemServices
import spock.lang.Unroll

class EnableFileSystemWatchingIntegrationTest extends AbstractFileSystemWatchingIntegrationTest {
Expand Down Expand Up @@ -86,40 +85,4 @@ class EnableFileSystemWatchingIntegrationTest extends AbstractFileSystemWatching
"--watch-fs" | ENABLED_MESSAGE
"--no-watch-fs" | DISABLED_MESSAGE
}
@Unroll
@SuppressWarnings('GrDeprecatedAPIUsage')
def "deprecation message is shown when using old VFS retention property to enable watching the file system (enabled: #enabled)"() {
buildFile << """
apply plugin: "java"
"""
executer.expectDocumentedDeprecationWarning(
"Using the system property org.gradle.unsafe.vfs.retention to enable watching the file system has been deprecated. " +
"This is scheduled to be removed in Gradle 7.0. " +
"Use the gradle property org.gradle.vfs.watch instead. " +
"See https://docs.gradle.org/current/userguide/gradle_daemon.html for more details."
)
expect:
succeeds("assemble", "-D${VirtualFileSystemServices.DEPRECATED_VFS_RETENTION_ENABLED_PROPERTY}=${enabled}")
where:
enabled << [true, false]
}
@Unroll
@SuppressWarnings('GrDeprecatedAPIUsage')
def "deprecation message is shown when using the old property to drop the VFS (drop: #drop)"() {
executer.expectDeprecationWarning(
"The org.gradle.unsafe.vfs.drop system property has been deprecated. " +
"This is scheduled to be removed in Gradle 7.0. " +
"Please use the org.gradle.vfs.drop system property instead."
)
expect:
succeeds("help", "--watch-fs", "-D${VirtualFileSystemServices.DEPRECATED_VFS_DROP_PROPERTY}=${drop}")
where:
drop << [true, false]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import org.gradle.api.internal.GradleInternal;
import org.gradle.api.internal.StartParameterInternal;
import org.gradle.api.internal.changedetection.state.FileHasherStatistics;
import org.gradle.initialization.StartParameterBuildOptions;
import org.gradle.internal.deprecation.DeprecationLogger;
import org.gradle.internal.file.StatStatistics;
import org.gradle.internal.invocation.BuildAction;
import org.gradle.internal.invocation.BuildActionRunner;
Expand Down Expand Up @@ -71,7 +69,6 @@ public Result run(BuildAction action, BuildController buildController) {
? WatchLogging.DEBUG
: WatchLogging.NORMAL;

logMessageForDeprecatedVfsRetentionProperty(startParameter);
LOGGER.info("Watching the file system is {}", watchFileSystemMode.getDescription());
if (watchFileSystemMode.isEnabled()) {
dropVirtualFileSystemIfRequested(startParameter, virtualFileSystem);
Expand Down Expand Up @@ -117,16 +114,4 @@ private static void dropVirtualFileSystemIfRequested(StartParameterInternal star
virtualFileSystem.invalidateAll();
}
}

private static void logMessageForDeprecatedVfsRetentionProperty(StartParameterInternal startParameter) {
if (VirtualFileSystemServices.isDeprecatedVfsRetentionPropertyPresent(startParameter)) {
@SuppressWarnings("deprecation")
String deprecatedVfsRetentionEnabledProperty = VirtualFileSystemServices.DEPRECATED_VFS_RETENTION_ENABLED_PROPERTY;
DeprecationLogger.deprecateIndirectUsage("Using the system property " + deprecatedVfsRetentionEnabledProperty + " to enable watching the file system")
.withAdvice("Use the gradle property " + StartParameterBuildOptions.WatchFileSystemOption.GRADLE_PROPERTY + " instead.")
.willBeRemovedInGradle7()
.withUserManual("gradle_daemon")
.nagUser();
}
}
}

0 comments on commit 363d057

Please sign in to comment.