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.");