Simplify ConfiguredValueCreationException

- Reduce excessive constructor overload
- Move withoutMessage() logic to the caller (where the intention is expressed).
- Replaced ConfiguredTargetFunctionException with ReportedException /
  UnreportedException to force explicit declaration of whether the error was
  directly reported in CTF.

PiperOrigin-RevId: 384235733
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BUILD b/src/main/java/com/google/devtools/build/lib/analysis/BUILD
index b10d26a..a98c1b7 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/BUILD
+++ b/src/main/java/com/google/devtools/build/lib/analysis/BUILD
@@ -207,7 +207,6 @@
         "SingleRunfilesSupplier.java",
         "SourceManifestAction.java",
         "StarlarkProviderValidationUtil.java",
-        "TargetAndConfiguration.java",
         "TargetCompleteEvent.java",
         "TargetContext.java",
         "TopLevelArtifactHelper.java",
@@ -346,6 +345,7 @@
         ":starlark/starlark_exec_group_collection",
         ":starlark/starlark_late_bound_default",
         ":starlark/starlark_toolchain_context",
+        ":target_and_configuration",
         ":template_variable_info",
         ":test/analysis_failure",
         ":test/analysis_failure_info",
@@ -598,6 +598,7 @@
         ":constraints/top_level_constraint_semantics",
         ":extra_action_artifacts_provider",
         ":make_environment_event",
+        ":target_and_configuration",
         ":target_configured_event",
         ":test/coverage_report_action_factory",
         ":test/instrumented_files_info",
@@ -1034,6 +1035,20 @@
 )
 
 java_library(
+    name = "target_and_configuration",
+    srcs = ["TargetAndConfiguration.java"],
+    deps = [
+        ":config/build_configuration",
+        "//src/main/java/com/google/devtools/build/lib/cmdline",
+        "//src/main/java/com/google/devtools/build/lib/concurrent",
+        "//src/main/java/com/google/devtools/build/lib/packages",
+        "//src/main/java/com/google/devtools/build/lib/skyframe:configured_target_key",
+        "//third_party:guava",
+        "//third_party:jsr305",
+    ],
+)
+
+java_library(
     name = "target_configured_event",
     srcs = ["TargetConfiguredEvent.java"],
     deps = [
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigurationResolver.java b/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigurationResolver.java
index e20297a..47f66dd 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigurationResolver.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigurationResolver.java
@@ -219,11 +219,7 @@
         return null; // Need more Skyframe deps for a Starlark transition.
       }
     } catch (TransitionException e) {
-      throw new ConfiguredValueCreationException(
-          ctgValue.getTarget().getLocation(),
-          e.getMessage(),
-          ctgValue.getLabel(),
-          ctgValue.getConfiguration());
+      throw new ConfiguredValueCreationException(ctgValue, e.getMessage());
     }
 
     if (depFragments.equals(getCurrentConfiguration().fragmentClasses())
@@ -258,11 +254,7 @@
         configurationKeys.put(transitionKey, buildConfigurationValueKey);
       }
     } catch (OptionsParsingException e) {
-      throw new ConfiguredValueCreationException(
-          ctgValue.getTarget().getLocation(),
-          e.getMessage(),
-          ctgValue.getLabel(),
-          ctgValue.getConfiguration());
+      throw new ConfiguredValueCreationException(ctgValue, e.getMessage());
     }
 
     Map<SkyKey, ValueOrException<InvalidConfigurationException>> depConfigValues =
@@ -294,11 +286,7 @@
         return null; // Need dependency configurations.
       }
     } catch (InvalidConfigurationException e) {
-      throw new ConfiguredValueCreationException(
-          ctgValue.getTarget().getLocation(),
-          e.getMessage(),
-          ctgValue.getLabel(),
-          ctgValue.getConfiguration());
+      throw new ConfiguredValueCreationException(ctgValue, e.getMessage());
     }
 
     return ImmutableList.sortedCopyOf(SPLIT_DEP_ORDERING, dependencies);
@@ -327,11 +315,7 @@
           return null; // Need more Skyframe deps for a Starlark transition.
         }
       } catch (TransitionException e) {
-        throw new ConfiguredValueCreationException(
-            ctgValue.getTarget().getLocation(),
-            e.getMessage(),
-            ctgValue.getLabel(),
-            ctgValue.getConfiguration());
+        throw new ConfiguredValueCreationException(ctgValue, e.getMessage());
       }
       if (!SplitTransition.equals(getCurrentConfiguration().getOptions(), toOptions.values())) {
         return ImmutableList.copyOf(toOptions.keySet());
diff --git a/src/main/java/com/google/devtools/build/lib/query2/BUILD b/src/main/java/com/google/devtools/build/lib/query2/BUILD
index 36dddca..28cf369 100644
--- a/src/main/java/com/google/devtools/build/lib/query2/BUILD
+++ b/src/main/java/com/google/devtools/build/lib/query2/BUILD
@@ -46,6 +46,7 @@
         "//src/main/java/com/google/devtools/build/lib/analysis:inconsistent_aspect_order_exception",
         "//src/main/java/com/google/devtools/build/lib/analysis:platform_configuration",
         "//src/main/java/com/google/devtools/build/lib/analysis:required_config_fragments_provider",
+        "//src/main/java/com/google/devtools/build/lib/analysis:target_and_configuration",
         "//src/main/java/com/google/devtools/build/lib/analysis:toolchain_collection",
         "//src/main/java/com/google/devtools/build/lib/analysis:toolchain_context",
         "//src/main/java/com/google/devtools/build/lib/buildeventstream",
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/BUILD b/src/main/java/com/google/devtools/build/lib/skyframe/BUILD
index 1186134..d914242 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/BUILD
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/BUILD
@@ -266,6 +266,7 @@
         "//src/main/java/com/google/devtools/build/lib/analysis:platform_options",
         "//src/main/java/com/google/devtools/build/lib/analysis:resolved_toolchain_context",
         "//src/main/java/com/google/devtools/build/lib/analysis:rule_configured_object_value",
+        "//src/main/java/com/google/devtools/build/lib/analysis:target_and_configuration",
         "//src/main/java/com/google/devtools/build/lib/analysis:toolchain_collection",
         "//src/main/java/com/google/devtools/build/lib/analysis:toolchain_context",
         "//src/main/java/com/google/devtools/build/lib/analysis:top_level_artifact_context",
@@ -1228,7 +1229,7 @@
     srcs = ["ConfiguredValueCreationException.java"],
     deps = [
         ":sane_analysis_exception",
-        "//src/main/java/com/google/devtools/build/lib/analysis:config/build_configuration",
+        "//src/main/java/com/google/devtools/build/lib/analysis:target_and_configuration",
         "//src/main/java/com/google/devtools/build/lib/buildeventstream/proto:build_event_stream_java_proto",
         "//src/main/java/com/google/devtools/build/lib/causes",
         "//src/main/java/com/google/devtools/build/lib/cmdline",
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java
index 8e091c5..5f1a8f6 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java
@@ -76,7 +76,6 @@
 import com.google.devtools.build.lib.packages.RuleClass;
 import com.google.devtools.build.lib.packages.RuleClassProvider;
 import com.google.devtools.build.lib.packages.Target;
-import com.google.devtools.build.lib.packages.TargetUtils;
 import com.google.devtools.build.lib.server.FailureDetails.Analysis;
 import com.google.devtools.build.lib.server.FailureDetails.Analysis.Code;
 import com.google.devtools.build.lib.server.FailureDetails.FailureDetail;
@@ -184,8 +183,8 @@
   }
 
   @Override
-  public SkyValue compute(SkyKey key, Environment env) throws ConfiguredTargetFunctionException,
-      InterruptedException {
+  public SkyValue compute(SkyKey key, Environment env)
+      throws ReportedException, UnreportedException, InterruptedException {
     if (shouldUnblockCpuWorkWhenFetchingDeps) {
       env =
           new StateInformingSkyFunctionEnvironment(
@@ -231,12 +230,13 @@
       if (!e.getMessage().isEmpty()) {
         env.getListener().handle(Event.error(pkg.getBuildFile().getLocation(), e.getMessage()));
       }
-      throw new ConfiguredTargetFunctionException(
+      throw new ReportedException(
           new ConfiguredValueCreationException(
               pkg.getBuildFile().getLocation(),
               e.getMessage(),
               label,
-              configuration,
+              configuration.getEventId(),
+              null,
               e.getDetailedExitCode()));
     }
     if (pkg.containsErrors()) {
@@ -307,11 +307,10 @@
         NestedSet<Cause> causes = transitiveRootCauses.build();
         env.getListener()
             .handle(Event.error(target.getLocation(), "Cannot compute config conditions"));
-        throw new ConfiguredTargetFunctionException(
+        throw new ReportedException(
             new ConfiguredValueCreationException(
-                target.getLocation(),
+                ctgValue,
                 "Cannot compute config conditions",
-                configuration,
                 causes,
                 getPrioritizedDetailedExitCode(causes)));
       }
@@ -334,17 +333,11 @@
               transitiveRootCauses);
       if (!transitiveRootCauses.isEmpty()) {
         NestedSet<Cause> causes = transitiveRootCauses.build();
-        throw new ConfiguredTargetFunctionException(
+        // TODO(bazel-team): consider reporting the error in this class vs. exporting it for
+        // BuildTool to handle. Calling code needs to be untangled for that to work and pass tests.
+        throw new UnreportedException(
             new ConfiguredValueCreationException(
-                target.getLocation(),
-                "Analysis failed",
-                configuration,
-                causes,
-                getPrioritizedDetailedExitCode(causes)),
-            // TODO(bazel-team): consider reporting the error in this class vs. exporting it for
-            // BuildTool to handle, as stripMessage=false applies. Calling code needs to be
-            // untangled for that to work and pass tests.
-            /*stripMessage=*/ false);
+                ctgValue, "Analysis failed", causes, getPrioritizedDetailedExitCode(causes)));
       }
       if (env.valuesMissing()) {
         return null;
@@ -375,9 +368,7 @@
           createConfiguredTarget(
               view,
               env,
-              target,
-              configuration,
-              configuredTargetKey,
+              ctgValue,
               depValueMap,
               configConditions,
               toolchainContexts,
@@ -414,29 +405,21 @@
         }
       }
 
-      throw new ConfiguredTargetFunctionException(
+      throw new ReportedException(
           cvce != null
               ? cvce
               : new ConfiguredValueCreationException(
-                  target.getLocation(),
-                  errorMessage,
-                  target.getLabel(),
-                  configuration,
-                  e.getDetailedExitCode()));
+                  ctgValue, errorMessage, null, e.getDetailedExitCode()));
     } catch (ConfiguredValueCreationException e) {
       if (!e.getMessage().isEmpty()) {
         // Report the error to the user.
         env.getListener().handle(Event.error(e.getLocation(), e.getMessage()));
       }
-      throw new ConfiguredTargetFunctionException(e);
+      throw new ReportedException(e);
     } catch (AspectCreationException e) {
-      throw new ConfiguredTargetFunctionException(
+      throw new ReportedException(
           new ConfiguredValueCreationException(
-              target.getLocation(),
-              e.getMessage(),
-              configuration,
-              e.getCauses(),
-              e.getDetailedExitCode()));
+              ctgValue, e.getMessage(), e.getCauses(), e.getDetailedExitCode()));
     } catch (ToolchainException e) {
       String message =
           String.format(
@@ -445,18 +428,13 @@
       ConfiguredValueCreationException cvce = asConfiguredValueCreationException(e);
       if (cvce == null) {
         cvce =
-            new ConfiguredValueCreationException(
-                target.getLocation(),
-                message,
-                target.getLabel(),
-                configuration,
-                e.getDetailedExitCode());
+            new ConfiguredValueCreationException(ctgValue, message, null, e.getDetailedExitCode());
       }
       if (!message.isEmpty()) {
         // Report the error to the user.
         env.getListener().handle(Event.error(target.getLocation(), message));
       }
-      throw new ConfiguredTargetFunctionException(cvce);
+      throw new ReportedException(cvce);
     } finally {
       maybeReleaseSemaphore();
     }
@@ -686,7 +664,7 @@
       env.getListener().post(new AnalysisRootCauseEvent(configuration, label, e.getMessage()));
       throw new DependencyEvaluationException(
           new ConfiguredValueCreationException(
-              e.getLocation(), e.getMessage(), label, configuration),
+              e.getLocation(), e.getMessage(), label, configuration.getEventId(), null, null),
           // These errors occur within DependencyResolver, which is attached to the current target.
           // i.e. no dependent ConfiguredTargetFunction call happens to report its own error.
           /*depReportedOwnError=*/ false);
@@ -733,8 +711,7 @@
       return AspectResolver.mergeAspects(depValueNames, depValues, depAspects);
     } catch (DuplicateException e) {
       throw new DependencyEvaluationException(
-          new ConfiguredValueCreationException(
-              ctgValue.getTarget().getLocation(), e.getMessage(), label, configuration),
+          new ConfiguredValueCreationException(ctgValue, e.getMessage()),
           /*depReportedOwnError=*/ false);
     }
   }
@@ -803,12 +780,9 @@
       // One of the config dependencies doesn't exist, and we need to report that. Unfortunately,
       // there's not enough information to know which configurable attribute has the problem.
       throw new ConfiguredValueCreationException(
-          target.getLocation(),
           // The precise error is reported by the dependency that failed to load.
           // TODO(gregce): beautify this error: https://github.com/bazelbuild/bazel/issues/11984.
-          "errors encountered resolving select() keys for " + target.getLabel(),
-          target.getLabel(),
-          ctgValue.getConfiguration());
+          ctgValue, "errors encountered resolving select() keys for " + target.getLabel());
     }
 
     ImmutableMap.Builder<Label, ConfiguredTargetAndData> asConfiguredTargets =
@@ -833,11 +807,7 @@
                     "To inspect the select(), run: bazel query --output=build %s.\n",
                     target.getLabel())
                 + "For more help, see https://docs.bazel.build/be/functions.html#select.\n\n";
-        throw new ConfiguredValueCreationException(
-            TargetUtils.getLocationMaybe(target),
-            message,
-            ctgValue.getLabel(),
-            ctgValue.getConfiguration());
+        throw new ConfiguredValueCreationException(ctgValue, message);
       }
     }
 
@@ -963,11 +933,7 @@
     if (rootError != null) {
       throw new DependencyEvaluationException(
           new ConfiguredValueCreationException(
-              rootError.getLocation(),
-              rootError.getMessage(),
-              ctgValue.getConfiguration(),
-              transitiveRootCauses.build(),
-              detailedExitCode),
+              ctgValue, rootError.getMessage(), transitiveRootCauses.build(), detailedExitCode),
           /*depReportedOwnError=*/ true);
     } else if (missedValues) {
       return null;
@@ -985,15 +951,17 @@
   private static ConfiguredTargetValue createConfiguredTarget(
       SkyframeBuildView view,
       Environment env,
-      Target target,
-      BuildConfiguration configuration,
-      ConfiguredTargetKey configuredTargetKey,
+      TargetAndConfiguration ctgValue,
       OrderedSetMultimap<DependencyKind, ConfiguredTargetAndData> depValueMap,
       ConfigConditions configConditions,
       @Nullable ToolchainCollection<ResolvedToolchainContext> toolchainContexts,
       ExecGroupCollection.Builder execGroupCollectionBuilder,
       @Nullable NestedSetBuilder<Package> transitivePackagesForPackageRootResolution)
       throws ConfiguredValueCreationException, InterruptedException {
+    Target target = ctgValue.getTarget();
+    BuildConfiguration configuration = ctgValue.getConfiguration();
+    ConfiguredTargetKey configuredTargetKey = ctgValue.getConfiguredTargetKey();
+
     // Should be successfully evaluated and cached from the loading phase.
     StarlarkBuiltinsValue starlarkBuiltinsValue =
         (StarlarkBuiltinsValue) env.getValue(StarlarkBuiltinsValue.key());
@@ -1023,8 +991,7 @@
       Preconditions.checkState(env.valuesMissing(), e.getMessage());
       return null;
     } catch (ActionConflictException | InvalidExecGroupException e) {
-      throw new ConfiguredValueCreationException(
-          target.getLocation(), e.getMessage(), target.getLabel(), configuration);
+      throw new ConfiguredValueCreationException(ctgValue, e.getMessage());
     }
 
     events.replayOn(env.getListener());
@@ -1045,10 +1012,7 @@
                               createDetailedExitCode(event.getMessage())))
                   .collect(Collectors.toList()));
       throw new ConfiguredValueCreationException(
-          target.getLocation(),
-          "Analysis of target '" + target.getLabel() + "' failed",
-          configuration,
-          rootCauses);
+          ctgValue, "Analysis of target '" + target.getLabel() + "' failed", rootCauses, null);
     }
     Preconditions.checkState(!analysisEnvironment.hasErrors(),
         "Analysis environment hasError() but no errors reported");
@@ -1100,22 +1064,34 @@
   }
 
   /**
-   * Used to declare all the exception types that can be wrapped in the exception thrown by {@link
-   * ConfiguredTargetFunction#compute}.
+   * {@link ConfiguredTargetFunction#compute} exception that has already had its error reported to
+   * the user. Callers (like {@link BuildTool}) won't also report the error.
    */
-  private static final class ConfiguredTargetFunctionException extends SkyFunctionException {
-    ConfiguredTargetFunctionException(ConfiguredValueCreationException e) {
-      this(e, /*stripMessage=*/ true);
+  private static class ReportedException extends SkyFunctionException {
+    private ReportedException(ConfiguredValueCreationException e) {
+      super(withoutMessage(e), Transience.PERSISTENT);
     }
 
-    private ConfiguredTargetFunctionException(
-        ConfiguredValueCreationException e, boolean stripMessage) {
-      // Stripping the message guarantees no caller to ConfiguredTargetFunction can also report it
-      // to the console (BuildTool does this). This prevents confusing duplicate error output. In
-      // return, call sites within ConfiguredTargetFunction must remember to dutifully report the
-      // error.
-      super(stripMessage ? e.withoutMessage() : e, Transience.PERSISTENT);
+    /** Clones a {@link ConfiguredValueCreationException} with its {@code message} field removed. */
+    private static ConfiguredValueCreationException withoutMessage(
+        ConfiguredValueCreationException orig) {
+      return new ConfiguredValueCreationException(
+          orig.getLocation(),
+          "",
+          /*label=*/ null,
+          orig.getConfiguration(),
+          orig.getRootCauses(),
+          orig.getDetailedExitCode());
     }
+  }
 
+  /**
+   * {@link ConfiguredTargetFunction#compute} exception that has not had its error reported to the
+   * user. Callers (like {@link BuildTool}) are responsible for reporting the error.
+   */
+  private static class UnreportedException extends SkyFunctionException {
+    private UnreportedException(ConfiguredValueCreationException e) {
+      super(e, Transience.PERSISTENT);
+    }
   }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredValueCreationException.java b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredValueCreationException.java
index 464696d..a23b02d 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredValueCreationException.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredValueCreationException.java
@@ -13,7 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.skyframe;
 
-import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
+import com.google.devtools.build.lib.analysis.TargetAndConfiguration;
 import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.BuildEventId;
 import com.google.devtools.build.lib.causes.AnalysisFailedCause;
 import com.google.devtools.build.lib.causes.Cause;
@@ -41,80 +41,46 @@
   //  that specify the general Code.CONFIGURED_VALUE_CREATION_FAILED
   private final DetailedExitCode detailedExitCode;
 
-  private ConfiguredValueCreationException(
+  public ConfiguredValueCreationException(
       Location location,
       String message,
+      Label label,
       @Nullable BuildEventId configuration,
-      NestedSet<Cause> rootCauses,
-      DetailedExitCode detailedExitCode) {
+      @Nullable NestedSet<Cause> rootCauses,
+      @Nullable DetailedExitCode detailedExitCode) {
     super(message);
     this.location = location;
     this.configuration = configuration;
-    this.rootCauses = rootCauses;
-    this.detailedExitCode = detailedExitCode;
-  }
-
-  /**
-   * Returns a new copy with {@code message} emptied.
-   *
-   * <p>{@link BuildTool} reports exception messages to the console. but {@link
-   * ConfiguredTargetFunction} handles error reporting internally. Clearing out the message prevents
-   * both places from reporting it.
-   */
-  public ConfiguredValueCreationException withoutMessage() {
-    return new ConfiguredValueCreationException(
-        location, "", configuration, rootCauses, detailedExitCode);
+    this.detailedExitCode =
+        detailedExitCode != null ? detailedExitCode : createDetailedExitCode(message);
+    this.rootCauses =
+        rootCauses != null
+            ? rootCauses
+            : NestedSetBuilder.<Cause>stableOrder()
+                .add(
+                    new AnalysisFailedCause(
+                        label,
+                        configuration == null ? null : configuration.getConfiguration(),
+                        this.detailedExitCode))
+                .build();
   }
 
   public ConfiguredValueCreationException(
-      Location location,
+      TargetAndConfiguration ctgValue,
       String message,
-      Label currentTarget,
-      @Nullable BuildConfiguration configuration,
-      DetailedExitCode detailedExitCode) {
-    // TODO(bazel-team): the constructors are a bit out of control. Try a builder pattern.
+      @Nullable NestedSet<Cause> rootCauses,
+      @Nullable DetailedExitCode detailedExitCode) {
     this(
-        location,
+        ctgValue.getTarget().getLocation(),
         message,
-        configuration == null ? null : configuration.getEventId(),
-        NestedSetBuilder.<Cause>stableOrder()
-            .add(
-                new AnalysisFailedCause(
-                    currentTarget,
-                    configuration == null ? null : configuration.getEventId().getConfiguration(),
-                    detailedExitCode))
-            .build(),
+        ctgValue.getLabel(),
+        ctgValue.getConfiguration() == null ? null : ctgValue.getConfiguration().getEventId(),
+        rootCauses,
         detailedExitCode);
   }
 
-  public ConfiguredValueCreationException(
-      Location location,
-      String message,
-      Label currentTarget,
-      @Nullable BuildConfiguration configuration) {
-    this(location, message, currentTarget, configuration, createDetailedExitCode(message));
-  }
-
-  public ConfiguredValueCreationException(
-      Location location,
-      String message,
-      @Nullable BuildConfiguration configuration,
-      NestedSet<Cause> rootCauses,
-      @Nullable DetailedExitCode detailedExitCode) {
-    this(
-        location,
-        message,
-        configuration == null ? null : configuration.getEventId(),
-        rootCauses,
-        detailedExitCode != null ? detailedExitCode : createDetailedExitCode(message));
-  }
-
-  public ConfiguredValueCreationException(
-      Location location,
-      String message,
-      @Nullable BuildConfiguration configuration,
-      NestedSet<Cause> rootCauses) {
-    this(location, message, configuration, rootCauses, createDetailedExitCode(message));
+  public ConfiguredValueCreationException(TargetAndConfiguration ctgValue, String message) {
+    this(ctgValue, message, /*rootCauses=*/ null, /*detailedExitCode=*/ null);
   }
 
   public Location getLocation() {
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/BUILD b/src/test/java/com/google/devtools/build/lib/analysis/BUILD
index 0b96d3c..a0e41a7 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/analysis/BUILD
@@ -102,6 +102,7 @@
         "//src/main/java/com/google/devtools/build/lib/analysis:starlark/args",
         "//src/main/java/com/google/devtools/build/lib/analysis:starlark/function_transition_util",
         "//src/main/java/com/google/devtools/build/lib/analysis:starlark/starlark_custom_command_line",
+        "//src/main/java/com/google/devtools/build/lib/analysis:target_and_configuration",
         "//src/main/java/com/google/devtools/build/lib/analysis:test/analysis_failure",
         "//src/main/java/com/google/devtools/build/lib/analysis:test/analysis_failure_info",
         "//src/main/java/com/google/devtools/build/lib/analysis:test/instrumented_files_info",
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BUILD b/src/test/java/com/google/devtools/build/lib/analysis/util/BUILD
index 401e867..9760aa1 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/util/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BUILD
@@ -74,6 +74,7 @@
         "//src/main/java/com/google/devtools/build/lib/analysis:resolved_toolchain_context",
         "//src/main/java/com/google/devtools/build/lib/analysis:rule_definition_environment",
         "//src/main/java/com/google/devtools/build/lib/analysis:server_directories",
+        "//src/main/java/com/google/devtools/build/lib/analysis:target_and_configuration",
         "//src/main/java/com/google/devtools/build/lib/analysis:test/coverage_report_action_factory",
         "//src/main/java/com/google/devtools/build/lib/analysis:test/instrumented_files_info",
         "//src/main/java/com/google/devtools/build/lib/analysis:toolchain_collection",
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/BUILD b/src/test/java/com/google/devtools/build/lib/skyframe/BUILD
index 82bbfee..2063739 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/BUILD
@@ -145,6 +145,7 @@
         "//src/main/java/com/google/devtools/build/lib/analysis:platform_configuration",
         "//src/main/java/com/google/devtools/build/lib/analysis:platform_options",
         "//src/main/java/com/google/devtools/build/lib/analysis:server_directories",
+        "//src/main/java/com/google/devtools/build/lib/analysis:target_and_configuration",
         "//src/main/java/com/google/devtools/build/lib/analysis:test/test_configuration",
         "//src/main/java/com/google/devtools/build/lib/analysis:toolchain_collection",
         "//src/main/java/com/google/devtools/build/lib/analysis:top_level_artifact_context",