Introduce --incompatible_remove_local_resources to begin deprecating --local_resources.

If --incompatible_remove_local_resources=true, the build will fail with an ExecutorInitException if --local_resources is passed.

PiperOrigin-RevId: 240196119
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
index d648150..f7c854c 100644
--- a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
+++ b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
@@ -171,6 +171,12 @@
                 actionContextProviders,
                 options.testStrategy,
                 options.incompatibleListBasedExecutionStrategySelection);
+
+    if (options.availableResources != null && options.removeLocalResources) {
+      throw new ExecutorInitException(
+          "--local_resources is deprecated. Please use "
+              + "--local_ram_resources and/or --local_cpu_resources");
+    }
   }
 
   Executor getExecutor() throws ExecutorInitException {
@@ -641,7 +647,7 @@
     ResourceManager resourceMgr = ResourceManager.instance();
     ExecutionOptions options = request.getOptions(ExecutionOptions.class);
     ResourceSet resources;
-    if (options.availableResources != null) {
+    if (options.availableResources != null && !options.removeLocalResources) {
       logger.warning(
           "--local_resources will be deprecated. Please use --local_ram_resources "
               + "and/or --local_cpu_resources.");
diff --git a/src/main/java/com/google/devtools/build/lib/exec/ExecutionOptions.java b/src/main/java/com/google/devtools/build/lib/exec/ExecutionOptions.java
index e3099fc..3247b924 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/ExecutionOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/ExecutionOptions.java
@@ -314,6 +314,20 @@
   public ResourceSet availableResources;
 
   @Option(
+      name = "incompatible_remove_local_resources",
+      defaultValue = "false",
+      documentationCategory = OptionDocumentationCategory.EXECUTION_STRATEGY,
+      effectTags = {OptionEffectTag.EXECUTION},
+      metadataTags = {
+        OptionMetadataTag.INCOMPATIBLE_CHANGE,
+        OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
+      },
+      help =
+          "Deprecate local_resources in favor of --local_ram_resources and "
+              + "--local_cpu_resources.")
+  public boolean removeLocalResources;
+
+  @Option(
       name = "local_cpu_resources",
       defaultValue = "HOST_CPUS",
       documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,