Remove third party license checking from Bazel.

This doesn't remove --incompatible_disable_third_party_license_checking
but makes it a no-op. This is so the Google version of Bazel can migrate
on its own timeframe.

Because this logic was created before Bazel existed, removing it
from Google is going to take more time. We don't want that to slow
Bazel development.

See https://github.com/bazelbuild/bazel/issues/7444.

PiperOrigin-RevId: 241946385
diff --git a/src/main/java/com/google/devtools/build/lib/BUILD b/src/main/java/com/google/devtools/build/lib/BUILD
index 119de1b..d1c5fa3 100644
--- a/src/main/java/com/google/devtools/build/lib/BUILD
+++ b/src/main/java/com/google/devtools/build/lib/BUILD
@@ -816,22 +816,6 @@
 )
 
 java_library(
-    name = "bazel/LicenseCheckingModule",
-    srcs = ["bazel/LicenseCheckingModule.java"],
-    deps = [
-        ":build-base",
-        ":events",
-        ":packages-internal",
-        ":runtime",
-        "//src/main/java/com/google/devtools/build/lib/cmdline",
-        "//src/main/java/com/google/devtools/build/lib/collect",
-        "//src/main/java/com/google/devtools/build/lib/collect/nestedset",
-        "//src/main/java/com/google/devtools/build/lib/profiler",
-        "//third_party:guava",
-    ],
-)
-
-java_library(
     name = "bazel-main",
     srcs = ["bazel/Bazel.java"],
     resources = [
@@ -869,10 +853,8 @@
         exclude = [
             "bazel/Bazel.java",
             "bazel/BazelRepositoryModule.java",
-            "bazel/LicenseCheckingModule.java",
         ],
     ),
-    exports = [":bazel/LicenseCheckingModule"],
     deps = [
         ":build-base",
         ":build-info",
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/Bazel.java b/src/main/java/com/google/devtools/build/lib/bazel/Bazel.java
index 4ece65e..f2829af 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/Bazel.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/Bazel.java
@@ -43,7 +43,6 @@
           com.google.devtools.build.lib.bazel.BazelWorkspaceStatusModule.class,
           com.google.devtools.build.lib.bazel.BazelDiffAwarenessModule.class,
           com.google.devtools.build.lib.bazel.BazelRepositoryModule.class,
-          com.google.devtools.build.lib.bazel.LicenseCheckingModule.class,
           com.google.devtools.build.lib.bazel.debug.WorkspaceRuleModule.class,
           com.google.devtools.build.lib.bazel.coverage.BazelCoverageReportModule.class,
           com.google.devtools.build.lib.skylarkdebug.module.SkylarkDebuggerModule.class,
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/LicenseCheckingModule.java b/src/main/java/com/google/devtools/build/lib/bazel/LicenseCheckingModule.java
deleted file mode 100644
index 6cb5025..0000000
--- a/src/main/java/com/google/devtools/build/lib/bazel/LicenseCheckingModule.java
+++ /dev/null
@@ -1,261 +0,0 @@
-// Copyright 2019 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//    http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.bazel;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.HashBasedTable;
-import com.google.common.collect.ImmutableTable;
-import com.google.common.collect.Table;
-import com.google.devtools.build.lib.analysis.ConfiguredTarget;
-import com.google.devtools.build.lib.analysis.LicensesProvider;
-import com.google.devtools.build.lib.analysis.LicensesProvider.TargetLicense;
-import com.google.devtools.build.lib.analysis.StaticallyLinkedMarkerProvider;
-import com.google.devtools.build.lib.analysis.ViewCreationFailedException;
-import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
-import com.google.devtools.build.lib.analysis.config.BuildOptions;
-import com.google.devtools.build.lib.buildtool.BuildRequest;
-import com.google.devtools.build.lib.cmdline.Label;
-import com.google.devtools.build.lib.collect.nestedset.NestedSet;
-import com.google.devtools.build.lib.events.Event;
-import com.google.devtools.build.lib.events.EventHandler;
-import com.google.devtools.build.lib.events.Location;
-import com.google.devtools.build.lib.packages.InputFile;
-import com.google.devtools.build.lib.packages.License;
-import com.google.devtools.build.lib.packages.License.DistributionType;
-import com.google.devtools.build.lib.packages.License.LicenseType;
-import com.google.devtools.build.lib.packages.NoSuchPackageException;
-import com.google.devtools.build.lib.packages.NoSuchTargetException;
-import com.google.devtools.build.lib.packages.Rule;
-import com.google.devtools.build.lib.packages.StarlarkSemanticsOptions;
-import com.google.devtools.build.lib.packages.Target;
-import com.google.devtools.build.lib.packages.TargetUtils;
-import com.google.devtools.build.lib.profiler.ProfilePhase;
-import com.google.devtools.build.lib.profiler.Profiler;
-import com.google.devtools.build.lib.profiler.SilentCloseable;
-import com.google.devtools.build.lib.runtime.BlazeModule;
-import com.google.devtools.build.lib.runtime.CommandEnvironment;
-import java.util.EnumSet;
-import java.util.Set;
-
-/**
- * Module responsible for checking third party license compliance.
- *
- * <p><b>This is outdated logic marked for removal.</b> See <a
- * href="https://github.com/bazelbuild/bazel/issues/7444">#7444</a> for details.
- */
-public class LicenseCheckingModule extends BlazeModule {
-
-  protected boolean shouldCheckLicenses(BuildRequest request, BuildOptions buildOptions) {
-    if (request.getOptions(StarlarkSemanticsOptions.class)
-        .incompatibleDisableThirdPartyLicenseChecking) {
-      return false;
-    }
-    return buildOptions.get(BuildConfiguration.Options.class).checkLicenses;
-  }
-
-  @Override
-  public void afterAnalysis(
-      CommandEnvironment env,
-      BuildRequest request,
-      BuildOptions buildOptions,
-      Iterable<ConfiguredTarget> configuredTargets)
-      throws InterruptedException, ViewCreationFailedException {
-    // Check licenses.
-    // We check licenses if the first target configuration has license checking enabled. Right
-    // now, it is not possible to have multiple target configurations with different settings
-    // for this flag, which allows us to take this short cut.
-    if (shouldCheckLicenses(request, buildOptions)) {
-      Profiler.instance().markPhase(ProfilePhase.LICENSE);
-      try (SilentCloseable c = Profiler.instance().profile("validateLicensingForTargets")) {
-        validateLicensingForTargets(env, configuredTargets, request.getKeepGoing());
-      }
-    }
-  }
-
-  /**
-   * Takes a set of configured targets, and checks if the distribution methods declared for the
-   * targets are compatible with the constraints imposed by their prerequisites' licenses.
-   *
-   * @param configuredTargets the targets to check
-   * @param keepGoing if false, and a licensing error is encountered, both generates an error
-   *     message on the reporter, <em>and</em> throws an exception. If true, then just generates a
-   *     message on the reporter.
-   * @throws ViewCreationFailedException if the license checking failed (and not --keep_going)
-   */
-  private static void validateLicensingForTargets(
-      CommandEnvironment env, Iterable<ConfiguredTarget> configuredTargets, boolean keepGoing)
-      throws ViewCreationFailedException {
-    for (ConfiguredTarget configuredTarget : configuredTargets) {
-      Target target = null;
-      try {
-        target = env.getPackageManager().getTarget(env.getReporter(), configuredTarget.getLabel());
-      } catch (NoSuchPackageException | NoSuchTargetException | InterruptedException e) {
-        env.getReporter().handle(Event.error("Failed to get target to validate license"));
-        throw new ViewCreationFailedException(
-            "Build aborted due to issue getting targets to validate licenses", e);
-      }
-
-      if (TargetUtils.isTestRule(target)) {
-        continue; // Tests are exempt from license checking
-      }
-
-      final Set<DistributionType> distribs = target.getDistributions();
-      StaticallyLinkedMarkerProvider markerProvider =
-          configuredTarget.getProvider(StaticallyLinkedMarkerProvider.class);
-      boolean staticallyLinked = markerProvider != null && markerProvider.isLinkedStatically();
-
-      LicensesProvider provider = configuredTarget.getProvider(LicensesProvider.class);
-      if (provider != null) {
-        NestedSet<TargetLicense> licenses = provider.getTransitiveLicenses();
-        for (TargetLicense targetLicense : licenses) {
-          if (!checkCompatibility(
-              targetLicense.getLicense(),
-              distribs,
-              target,
-              targetLicense.getLabel(),
-              env.getReporter(),
-              staticallyLinked)) {
-            if (!keepGoing) {
-              throw new ViewCreationFailedException("Build aborted due to licensing error");
-            }
-          }
-        }
-      } else if (target instanceof InputFile) {
-        // Input file targets do not provide licenses because they do not
-        // depend on the rule where their license is taken from. This is usually
-        // not a problem, because the transitive collection of licenses always
-        // hits the rule they come from, except when the input file is a
-        // top-level target. Thus, we need to handle that case specially here.
-        //
-        // See FileTarget#getLicense for more information about the handling of
-        // license issues with File targets.
-        License license = target.getLicense();
-        if (!checkCompatibility(
-            license,
-            distribs,
-            target,
-            configuredTarget.getLabel(),
-            env.getReporter(),
-            staticallyLinked)) {
-          if (!keepGoing) {
-            throw new ViewCreationFailedException("Build aborted due to licensing error");
-          }
-        }
-      }
-    }
-  }
-
-  private static final Object MARKER = new Object();
-
-  /**
-   * The license incompatibility set. This contains the set of (Distribution,License) pairs that
-   * should generate errors.
-   */
-  private static final Table<DistributionType, LicenseType, Object> licenseIncompatibilies =
-      createLicenseIncompatibilitySet();
-
-  private static Table<DistributionType, LicenseType, Object> createLicenseIncompatibilitySet() {
-    Table<DistributionType, LicenseType, Object> result = HashBasedTable.create();
-    result.put(DistributionType.CLIENT, LicenseType.RESTRICTED, MARKER);
-    result.put(DistributionType.EMBEDDED, LicenseType.RESTRICTED, MARKER);
-    result.put(DistributionType.INTERNAL, LicenseType.BY_EXCEPTION_ONLY, MARKER);
-    result.put(DistributionType.CLIENT, LicenseType.BY_EXCEPTION_ONLY, MARKER);
-    result.put(DistributionType.WEB, LicenseType.BY_EXCEPTION_ONLY, MARKER);
-    result.put(DistributionType.EMBEDDED, LicenseType.BY_EXCEPTION_ONLY, MARKER);
-    return ImmutableTable.copyOf(result);
-  }
-
-  /**
-   * The license warning set. This contains the set of (Distribution,License) pairs that should
-   * generate warnings when the user requests verbose license checking.
-   */
-  private static final Table<DistributionType, LicenseType, Object> licenseWarnings =
-      createLicenseWarningsSet();
-
-  private static Table<DistributionType, LicenseType, Object> createLicenseWarningsSet() {
-    Table<DistributionType, LicenseType, Object> result = HashBasedTable.create();
-    result.put(DistributionType.CLIENT, LicenseType.RECIPROCAL, MARKER);
-    result.put(DistributionType.EMBEDDED, LicenseType.RECIPROCAL, MARKER);
-    result.put(DistributionType.CLIENT, LicenseType.NOTICE, MARKER);
-    result.put(DistributionType.EMBEDDED, LicenseType.NOTICE, MARKER);
-    return ImmutableTable.copyOf(result);
-  }
-
-  /**
-   * Checks if the given license is compatible with distributing a particular target in some set of
-   * distribution modes.
-   *
-   * @param license the license to check
-   * @param dists the modes of distribution
-   * @param target the target which is being checked, and which will be used for checking exceptions
-   * @param licensedTarget the target which declared the license being checked.
-   * @param eventHandler a reporter where any licensing issues discovered should be reported
-   * @param staticallyLinked whether the target is statically linked under this command
-   * @return true if the license is compatible with the distributions
-   */
-  @VisibleForTesting
-  public static boolean checkCompatibility(
-      License license,
-      Set<DistributionType> dists,
-      Target target,
-      Label licensedTarget,
-      EventHandler eventHandler,
-      boolean staticallyLinked) {
-    Location location = (target instanceof Rule) ? ((Rule) target).getLocation() : null;
-
-    LicenseType leastRestrictiveLicense;
-    if (license.getLicenseTypes().contains(LicenseType.RESTRICTED_IF_STATICALLY_LINKED)) {
-      Set<LicenseType> tempLicenses = EnumSet.copyOf(license.getLicenseTypes());
-      tempLicenses.remove(LicenseType.RESTRICTED_IF_STATICALLY_LINKED);
-      if (staticallyLinked) {
-        tempLicenses.add(LicenseType.RESTRICTED);
-      } else {
-        tempLicenses.add(LicenseType.UNENCUMBERED);
-      }
-      leastRestrictiveLicense = License.leastRestrictive(tempLicenses);
-    } else {
-      leastRestrictiveLicense = License.leastRestrictive(license.getLicenseTypes());
-    }
-    for (DistributionType dt : dists) {
-      if (licenseIncompatibilies.contains(dt, leastRestrictiveLicense)) {
-        if (!license.getExceptions().contains(target.getLabel())) {
-          eventHandler.handle(
-              Event.error(
-                  location,
-                  "Build target '"
-                      + target.getLabel()
-                      + "' is not compatible with license '"
-                      + license
-                      + "' from target '"
-                      + licensedTarget
-                      + "'"));
-          return false;
-        }
-      } else if (licenseWarnings.contains(dt, leastRestrictiveLicense)) {
-        eventHandler.handle(
-            Event.warn(
-                location,
-                "Build target '"
-                    + target
-                    + "' has a potential licensing issue with a '"
-                    + license
-                    + "' license from target '"
-                    + licensedTarget
-                    + "'"));
-      }
-    }
-    return true;
-  }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
index 29a9750..f89e03e 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
@@ -53,6 +53,7 @@
 import com.google.devtools.build.lib.bazel.rules.workspace.MavenJarRule;
 import com.google.devtools.build.lib.bazel.rules.workspace.MavenServerRule;
 import com.google.devtools.build.lib.cmdline.LabelConstants;
+import com.google.devtools.build.lib.packages.RuleClass.Builder.ThirdPartyLicenseExistencePolicy;
 import com.google.devtools.build.lib.rules.android.AarImportBaseRule;
 import com.google.devtools.build.lib.rules.android.AndroidConfiguration;
 import com.google.devtools.build.lib.rules.android.AndroidDeviceBrokerInfo;
@@ -198,9 +199,7 @@
   public static ConfiguredRuleClassProvider create() {
     ConfiguredRuleClassProvider.Builder builder = new ConfiguredRuleClassProvider.Builder();
     builder.setToolsRepository(TOOLS_REPOSITORY);
-    // TODO(gregce): uncomment the below line in the same change that retires
-    // --incompatible_disable_third_party_license_checking. See the flag's comments for details.
-    // builder.setThirdPartyLicenseExistencePolicy(ThirdPartyLicenseExistencePolicy.NEVER_CHECK);
+    builder.setThirdPartyLicenseExistencePolicy(ThirdPartyLicenseExistencePolicy.NEVER_CHECK);
     setup(builder);
     return builder.build();
   }
@@ -209,6 +208,7 @@
     for (RuleSet ruleSet : RULE_SETS) {
       ruleSet.init(builder);
     }
+    builder.setThirdPartyLicenseExistencePolicy(ThirdPartyLicenseExistencePolicy.NEVER_CHECK);
   }
 
   public static final RuleSet BAZEL_SETUP =
diff --git a/src/main/java/com/google/devtools/build/lib/packages/License.java b/src/main/java/com/google/devtools/build/lib/packages/License.java
index c980444..3c44a0e 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/License.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/License.java
@@ -14,7 +14,6 @@
 
 package com.google.devtools.build.lib.packages;
 
-import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Sets;
@@ -76,7 +75,6 @@
    * @param types a collection of license types
    * @return the least restrictive license type
    */
-  @VisibleForTesting
   public static LicenseType leastRestrictive(Collection<LicenseType> types) {
     // TODO(gregce): move this method to LicenseCheckingModule when Bazel's tests no longer use it
     return types.isEmpty() ? LicenseType.BY_EXCEPTION_ONLY : Collections.max(types);
diff --git a/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java b/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java
index 64c982b..9dc7cca 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java
@@ -751,9 +751,7 @@
             == ThirdPartyLicenseExistencePolicy.NEVER_CHECK) {
           checkLicenses = false;
         } else {
-          checkLicenses =
-              env.getSemantics().checkThirdPartyTargetsHaveLicenses()
-                  && !env.getSemantics().incompatibleDisableThirdPartyLicenseChecking();
+          checkLicenses = !env.getSemantics().incompatibleDisableThirdPartyLicenseChecking();
         }
 
         if (checkLicenses
diff --git a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
index 328a840..4bdf988 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
@@ -693,17 +693,20 @@
     public enum ThirdPartyLicenseExistencePolicy {
       /**
        * Always do this check, overriding whatever {@link
-       * StarlarkSemanticsOptions#checkThirdPartyTargetsHaveLicenses} says.
+       * StarlarkSemanticsOptions#incompatibleDisableThirdPartyLicenseChecking} says.
        */
       ALWAYS_CHECK,
 
       /**
        * Never do this check, overriding whatever {@link
-       * StarlarkSemanticsOptions#checkThirdPartyTargetsHaveLicenses} says.
+       * StarlarkSemanticsOptions#incompatibleDisableThirdPartyLicenseChecking} says.
        */
       NEVER_CHECK,
 
-      /** Do whatever {@link StarlarkSemanticsOptions#checkThirdPartyTargetsHaveLicenses} says. */
+      /**
+       * Do whatever {@link StarlarkSemanticsOptions#incompatibleDisableThirdPartyLicenseChecking}
+       * says.
+       */
       USER_CONTROLLABLE
     }
 
diff --git a/src/main/java/com/google/devtools/build/lib/packages/RuleFactory.java b/src/main/java/com/google/devtools/build/lib/packages/RuleFactory.java
index efea73a..35517ed 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/RuleFactory.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/RuleFactory.java
@@ -128,20 +128,14 @@
     AttributesAndLocation generator =
         generatorAttributesForMacros(attributeValues, env, location, label);
     try {
-      // Examines --check_third_party_targets_have_licenses and
-      // --incompatible_disable_third_party_license_checking to see if we should check third_party
-      // targets for license existence. The latter flag overrides the former.
+      // Examines --incompatible_disable_third_party_license_checking to see if we should check
+      // third party targets for license existence.
       //
-      // Note that *both* flags are overridable by RuleClass.ThirdPartyLicenseEnforcementPolicy
-      // (which is checked in RuleClass). This lets Bazel and Blaze migrate away from license logic
-      // on independent timelines. See --incompatible_disable_third_party_license_checking comments
-      // for details.
-      boolean checkThirdPartyLicenses;
-      if (env == null || env.getSemantics().incompatibleDisableThirdPartyLicenseChecking()) {
-        checkThirdPartyLicenses = false;
-      } else {
-        checkThirdPartyLicenses = env.getSemantics().checkThirdPartyTargetsHaveLicenses();
-      }
+      // This flag is overridable by RuleClass.ThirdPartyLicenseEnforcementPolicy (which is checked
+      // in RuleClass). This lets Bazel and Blaze migrate away from license logic on independent
+      // timelines. See --incompatible_disable_third_party_license_checking comments for details.
+      boolean checkThirdPartyLicenses =
+          env != null && !env.getSemantics().incompatibleDisableThirdPartyLicenseChecking();
       return ruleClass.createRule(
           pkgBuilder,
           label,
diff --git a/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java b/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java
index af68aa1..29a2f4a 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java
@@ -60,18 +60,6 @@
 
   // <== Add new options here in alphabetic order ==>
 
-  /**
-   * This can be overridden by {@link RuleClass.Builder.ThirdPartyLicenseExistencePolicy} and {@link
-   * #incompatibleDisableThirdPartyLicenseChecking}.
-   */
-  @Option(
-      name = "check_third_party_targets_have_licenses",
-      defaultValue = "true",
-      documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
-      effectTags = OptionEffectTag.BUILD_FILE_SEMANTICS,
-      help = "If true, all rules and files under //third_party must declare licenses([])")
-  public boolean checkThirdPartyTargetsHaveLicenses;
-
   @Option(
       name = "experimental_build_setting_api",
       defaultValue = "false",
@@ -221,22 +209,14 @@
       help = "If set to true, disallow use of deprecated resource fields on the Objc provider.")
   public boolean incompatibleDisableObjcProviderResources;
 
-  // Once this migration is complete, instead of removing this flag we need to make it a no-op.
-  // This is because we'll need to keep it around for a while so Google's migration can complete
-  // after Bazel's. This is an example of Bazel's Google roots being methodically torn out:
-  // because this functionality was introduced for Google before Bazel existed, Google's
-  // dependency on it is deeper. We don't want this to add unnecessary baggage to Bazel or slow
-  // down Bazel's development. So this approach, while slightly awkward, relieves Bazel of
-  // Google's technical debt (which shouldn't be Bazel's problem). This means you as a Bazel
-  // user are getting better code than Google has! (for a while, at least)
+  // For Bazel, this flag is a no-op. Bazel doesn't support built-in third party license checking
+  // (see https://github.com/bazelbuild/bazel/issues/7444).
   //
-  // Track migration at https://github.com/bazelbuild/bazel/issues/7444. When we're ready to
-  // remove Bazel support, instead of removing the flag we should do these things:
-  //
-  // 1) BazelRuleClassProvider: set the third party license existence policy to NEVER_CHECK (see
-  //    the related TODO(gregce) comment in that file).
-  // 2) Remove LicenseCheckingModule.
-  // 3) Remove --check_third_party_targets_have_licenses.
+  // For Blaze in Google, this flag is still needed to deprecate the logic that's already been
+  // removed from Bazel. That logic was introduced before Bazel existed, so Google's dependency on
+  // it is deeper. But we don't want that to add unnecessary baggage to Bazel or slow down Bazel's
+  // development. So this flag lets Blaze migrate on a slower timeline without blocking Bazel. This
+  // means you as a Bazel user are getting better code than Google has! (for a while, at least)
   @Option(
       name = "incompatible_disable_third_party_license_checking",
       defaultValue = "true",
@@ -246,9 +226,7 @@
         OptionMetadataTag.INCOMPATIBLE_CHANGE,
         OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
       },
-      help =
-          "If true, disables all license checking logic. This overrides "
-              + "--check_third_party_targets_have_licenses")
+      help = "If true, disables all license checking logic")
   public boolean incompatibleDisableThirdPartyLicenseChecking;
 
   @Option(
@@ -534,7 +512,6 @@
   public StarlarkSemantics toSkylarkSemantics() {
     return StarlarkSemantics.builder()
         // <== Add new options here in alphabetic order ==>
-        .checkThirdPartyTargetsHaveLicenses(checkThirdPartyTargetsHaveLicenses)
         .experimentalBuildSettingApi(experimentalBuildSettingApi)
         .experimentalCcSkylarkApiEnabledPackages(experimentalCcSkylarkApiEnabledPackages)
         .experimentalEnableAndroidMigrationApis(experimentalEnableAndroidMigrationApis)
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java b/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java
index e84aca4..f8a1dc0 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java
@@ -112,8 +112,6 @@
       AutoValue_StarlarkSemantics.class;
 
   // <== Add new options here in alphabetic order ==>
-  public abstract boolean checkThirdPartyTargetsHaveLicenses();
-
   public abstract boolean experimentalBuildSettingApi();
 
   public abstract ImmutableList<String> experimentalCcSkylarkApiEnabledPackages();
@@ -197,7 +195,6 @@
   public static final StarlarkSemantics DEFAULT_SEMANTICS =
       builder()
           // <== Add new options here in alphabetic order ==>
-          .checkThirdPartyTargetsHaveLicenses(true)
           .experimentalBuildSettingApi(false)
           .experimentalCcSkylarkApiEnabledPackages(ImmutableList.of())
           .experimentalEnableAndroidMigrationApis(false)
@@ -239,8 +236,6 @@
   public abstract static class Builder {
 
     // <== Add new options here in alphabetic order ==>
-    public abstract Builder checkThirdPartyTargetsHaveLicenses(boolean value);
-
     public abstract Builder experimentalBuildSettingApi(boolean value);
 
     public abstract Builder experimentalCcSkylarkApiEnabledPackages(List<String> value);
diff --git a/src/test/java/com/google/devtools/build/lib/BUILD b/src/test/java/com/google/devtools/build/lib/BUILD
index 3acba1a..a990099 100644
--- a/src/test/java/com/google/devtools/build/lib/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/BUILD
@@ -655,7 +655,6 @@
         "//src/main/java/com/google/devtools/build/lib:bazel-main",
         "//src/main/java/com/google/devtools/build/lib:bazel-repository",
         "//src/main/java/com/google/devtools/build/lib:bazel-rules",
-        "//src/main/java/com/google/devtools/build/lib:bazel/LicenseCheckingModule",
         "//src/main/java/com/google/devtools/build/lib:build-base",
         "//src/main/java/com/google/devtools/build/lib:build-request-options",
         "//src/main/java/com/google/devtools/build/lib:core-rules",
@@ -865,7 +864,6 @@
         ":testutil",
         "//src/main/java/com/google/devtools/build/lib:bazel-main",
         "//src/main/java/com/google/devtools/build/lib:bazel-rules",
-        "//src/main/java/com/google/devtools/build/lib:bazel/LicenseCheckingModule",
         "//src/main/java/com/google/devtools/build/lib:build-base",
         "//src/main/java/com/google/devtools/build/lib:events",
         "//src/main/java/com/google/devtools/build/lib:packages",
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java b/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java
index 8397f8d..b6bdb22 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java
@@ -276,44 +276,6 @@
   }
 
   @Test
-  public void testConvolutedLoadRootCauseAnalysis() throws Exception {
-    useConfiguration("--incompatible_disable_third_party_license_checking=false");
-    // You need license declarations in third_party. We use this constraint to
-    // create targets that are loadable, but are in error.
-    scratch.file("third_party/first/BUILD",
-        "sh_library(name='first', deps=['//third_party/second'], licenses=['notice'])");
-    scratch.file("third_party/second/BUILD",
-        "sh_library(name='second', deps=['//third_party/third'], licenses=['notice'])");
-    scratch.file("third_party/third/BUILD",
-        "sh_library(name='third', deps=['//third_party/fourth'], licenses=['notice'])");
-    scratch.file("third_party/fourth/BUILD",
-        "sh_library(name='fourth', deps=['//third_party/fifth'])");
-    scratch.file("third_party/fifth/BUILD",
-        "sh_library(name='fifth', licenses=['notice'])");
-    reporter.removeHandler(failFastHandler);
-    EventBus eventBus = new EventBus();
-    LoadingFailureRecorder recorder = new LoadingFailureRecorder();
-    eventBus.register(recorder);
-    // Note: no need to run analysis for a loading failure.
-    AnalysisResult result = update(eventBus, defaultFlags().with(Flag.KEEP_GOING),
-        "//third_party/first", "//third_party/third");
-    assertThat(result.hasError()).isTrue();
-    assertThat(recorder.events).hasSize(2);
-    assertWithMessage(recorder.events.toString())
-        .that(
-            recorder.events.contains(
-                new LoadingFailureEvent(
-                    Label.parseAbsolute("//third_party/first", ImmutableMap.of()),
-                    Label.parseAbsolute("//third_party/fourth", ImmutableMap.of()))))
-        .isTrue();
-    assertThat(recorder.events)
-        .contains(
-            new LoadingFailureEvent(
-                Label.parseAbsolute("//third_party/third", ImmutableMap.of()),
-                Label.parseAbsolute("//third_party/fourth", ImmutableMap.of())));
-  }
-
-  @Test
   public void testMultipleRootCauseReporting() throws Exception {
     scratch.file("gp/BUILD",
         "sh_library(name = 'gp', deps = ['//p:p'])");
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/LicensingTests.java b/src/test/java/com/google/devtools/build/lib/analysis/LicensingTests.java
deleted file mode 100644
index b34a6d6..0000000
--- a/src/test/java/com/google/devtools/build/lib/analysis/LicensingTests.java
+++ /dev/null
@@ -1,729 +0,0 @@
-// Copyright 2016 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//    http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-package com.google.devtools.build.lib.analysis;
-
-import static com.google.common.truth.Truth.assertThat;
-import static com.google.common.truth.Truth.assertWithMessage;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import com.google.common.testing.EqualsTester;
-import com.google.devtools.build.lib.analysis.LicensesProvider.TargetLicense;
-import com.google.devtools.build.lib.analysis.util.AnalysisMock;
-import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
-import com.google.devtools.build.lib.bazel.LicenseCheckingModule;
-import com.google.devtools.build.lib.cmdline.Label;
-import com.google.devtools.build.lib.cmdline.LabelSyntaxException;
-import com.google.devtools.build.lib.packages.License;
-import com.google.devtools.build.lib.packages.License.DistributionType;
-import com.google.devtools.build.lib.packages.License.LicenseParsingException;
-import com.google.devtools.build.lib.packages.RawAttributeMapper;
-import com.google.devtools.build.lib.packages.Rule;
-import com.google.devtools.build.lib.packages.util.MockCcSupport;
-import com.google.devtools.build.lib.syntax.Type;
-import java.util.Arrays;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-/**
- * Integration tests for {@link License}.
- */
-@RunWith(JUnit4.class)
-public class LicensingTests extends BuildViewTestCase {
-
-  /** Filter to remove implicit dependencies of sh_* rules. */
-  private static final Predicate<String> SH_LABEL_NAME_FILTER = new Predicate<String>() {
-    @Override
-    public boolean apply(String label) {
-      return !label.startsWith("//util/shell/");
-      }
-  };
-
-  private static final Predicate<Label> SH_LABEL_FILTER = new Predicate<Label>() {
-    @Override
-    public boolean apply(Label label) {
-      return SH_LABEL_NAME_FILTER.apply("//" + label.getPackageName());
-    }
-  };
-
-
-  /** Filter to remove implicit dependencies of Java rules. */
-  private static final Predicate<String> JAVA_LABEL_NAME_FILTER = new Predicate<String>() {
-    @Override
-    public boolean apply(String label) {
-      return !label.startsWith("//third_party/java/jdk");
-    }
-  };
-
-  public static final Predicate<Label> JAVA_LABEL_FILTER = new Predicate<Label>() {
-    @Override
-    public boolean apply(Label label) {
-      return JAVA_LABEL_NAME_FILTER.apply("//" + label.getPackageName());
-    }
-  };
-
-  @SuppressWarnings("unchecked")
-  public static final Predicate<Label> CC_OR_JAVA_OR_SH_LABEL_FILTER =
-      Predicates.and(
-          AnalysisMock.get().ccSupport().labelFilter(),
-          JAVA_LABEL_FILTER,
-          SH_LABEL_FILTER);
-
-  @Before
-  public final void useCorrectConfiguration() throws Exception {
-    useConfiguration("--check_licenses");
-  }
-
-  @Test
-  public void testCollectDistribs() throws Exception {
-    scratch.file("a/BUILD",
-        "distribs(['client', 'web'])",
-        "cc_library(name = 'alib', srcs=['a.cc'], deps=[':blib'])",
-        "cc_library(name = 'blib', distribs=['client'])");
-    scratch.file("kaboom/BUILD",
-        "cc_library(name = 'boom', srcs=['bang.cc'])");
-    assertThat(getTarget("//a:alib").getDistributions())
-        .containsExactlyElementsIn(
-            Sets.newHashSet(License.DistributionType.CLIENT, License.DistributionType.WEB));
-    assertThat(getTarget("//a:blib").getDistributions())
-        .containsExactlyElementsIn(Sets.newHashSet(License.DistributionType.CLIENT));
-    assertThat(getTarget("//kaboom:boom").getDistributions())
-        .containsExactlyElementsIn(Sets.newHashSet(License.DistributionType.INTERNAL));
-  }
-
-  // Same test, using package.distribs.
-  @Test
-  public void testCollectDistribsPackage() throws Exception {
-    scratch.file("a/BUILD",
-        "package(distribs = ['client', 'web'])",
-        "cc_library(name = 'alib', srcs=['a.cc'], deps=[':blib'])",
-        "cc_library(name = 'blib', distribs=['client'])");
-    scratch.file("kaboom/BUILD",
-        "cc_library(name = 'boom', srcs=['bang.cc'])");
-    assertThat(getTarget("//a:alib").getDistributions())
-        .containsExactlyElementsIn(
-            Sets.newHashSet(License.DistributionType.CLIENT, License.DistributionType.WEB));
-    assertThat(getTarget("//a:blib").getDistributions())
-        .containsExactlyElementsIn(Sets.newHashSet(License.DistributionType.CLIENT));
-    assertThat(getTarget("//kaboom:boom").getDistributions())
-        .containsExactlyElementsIn(Sets.newHashSet(License.DistributionType.INTERNAL));
-  }
-
-  // Test for package.licenses
-  @Test
-  public void testCollectLicensesPackage() throws Exception {
-    scratch.file("a/BUILD",
-        "licenses(['restricted', 'reciprocal'])",
-        "exports_files(['a'])");
-
-    ConfiguredTarget target = getConfiguredTarget("//a:a");
-    License license = getTarget(target.getLabel()).getLicense();
-    assertThat(license).isEqualTo(License.parseLicense(Arrays.asList("restricted", "reciprocal")));
-  }
-
-  @Test
-  public void testCollectLicenses() throws Exception {
-    Predicate<Label> SOURCE_FILTER =
-        new Predicate<Label>() {
-          @Override
-          public boolean apply(Label label) {
-            // Remove source files from the results.
-            return AnalysisMock.get().ccSupport().labelFilter().apply(label)
-                && !label.toString().endsWith(".cc");
-          }
-        };
-
-    scratch.file("a/BUILD",
-        "licenses(['restricted', 'reciprocal'])",
-        "cc_library(name = 'alib', srcs=['a.cc'], deps=[':blib'])",
-        "cc_library(name = 'blib', srcs=['b.cc'], distribs=['web'], "
-        + "deps=['//kaboom:boom', '//kablam:blam'])",
-        "exports_files(['c'])");
-    scratch.file("kaboom/BUILD",
-        "licenses(['notice'])",
-        "cc_library(name = 'boom', srcs=['bang.cc'])");
-    scratch.file("kablam/BUILD",
-        "licenses(['restricted','exception=//a:alib'])",
-        "cc_library(name='blam', srcs=['blam.cc'])");
-    ConfiguredTarget aTarget = getConfiguredTarget("//a:alib");
-    ConfiguredTarget bTarget = getConfiguredTarget("//a:blib");
-    ConfiguredTarget cTarget = getConfiguredTarget("//a:c");
-    ConfiguredTarget kaboomTarget = getConfiguredTarget("//kaboom:boom");
-    ConfiguredTarget kablamTarget = getConfiguredTarget("//kablam:blam");
-    Map<Label, License> aMap =
-        Maps.filterKeys(getTransitiveLicenses(aTarget), SOURCE_FILTER);
-    Map<Label, License> aExpected = licenses("//a:alib", "restricted,reciprocal",
-                                             "//a:blib", "restricted,reciprocal",
-                                             "//kablam:blam", "restricted,exception=//a:alib",
-                                             "//kaboom:boom", "notice");
-    assertSameMapEntries(aExpected, aMap);
-
-    Map<Label, License> bMap =
-        Maps.filterKeys(getTransitiveLicenses(bTarget), SOURCE_FILTER);
-    Map<Label, License> bExpected = licenses("//a:blib", "restricted,reciprocal",
-                                             "//kablam:blam", "restricted,exception=//a:alib",
-                                             "//kaboom:boom", "notice");
-    assertSameMapEntries(bExpected, bMap);
-
-    Map<Label, License> kaboomMap =
-        Maps.filterKeys(getTransitiveLicenses(kaboomTarget), SOURCE_FILTER);
-    assertSameMapEntries(
-        licenses("//kaboom:boom", "notice"),
-        kaboomMap);
-
-    Map<Label, License> kablamMap =
-        Maps.filterKeys(getTransitiveLicenses(kablamTarget), SOURCE_FILTER);
-    assertSameMapEntries(
-        licenses("//kablam:blam", "restricted,exception=//a:alib"),
-        kablamMap);
-
-    License cLicense = getTarget(cTarget.getLabel()).getLicense();
-    assertThat(cLicense).isEqualTo(License.parseLicense(Arrays.asList("restricted", "reciprocal")));
-  }
-
-  @Test
-  public void testClientLicenseOverridesDefault() throws Exception {
-    scratch.file("a/BUILD",
-        "licenses(['restricted', 'reciprocal'])",
-        "cc_library(name = 'alib', srcs=['a.cc'], deps=[':blib'], licenses=['unencumbered'])",
-        "cc_library(name = 'blib', srcs=['b.cc'], distribs=['web'])",
-        "exports_files(['c'], licenses = ['unencumbered'])");
-    ConfiguredTarget aTarget = getConfiguredTarget("//a:alib");
-    ConfiguredTarget bTarget = getConfiguredTarget("//a:blib");
-    ConfiguredTarget cTarget = getConfiguredTarget("//a:c");
-    License aLicense = getTarget(aTarget.getLabel()).getLicense();
-    License bLicense = getTarget(bTarget.getLabel()).getLicense();
-    License cLicense = getTarget(cTarget.getLabel()).getLicense();
-    assertThat(aLicense.equals(bLicense)).isFalse();
-    assertThat(aLicense).isEqualTo(License.parseLicense(Arrays.asList("unencumbered")));
-    assertThat(bLicense).isEqualTo(License.parseLicense(Arrays.asList("restricted", "reciprocal")));
-    assertThat(cLicense).isEqualTo(License.parseLicense(Arrays.asList("unencumbered")));
-  }
-
-  @Test
-  public void testNoneLicenseHandledCorrectly() throws Exception {
-    scratch.file("music/BUILD",
-        "sh_binary(name='piano', srcs=['piano.sh'], licenses=['none'])");
-    Map<Label, License> licenses = Maps.filterKeys(
-        getTransitiveLicenses(getConfiguredTarget("//music:piano")),
-        CC_OR_JAVA_OR_SH_LABEL_FILTER);
-    assertThat(licenses).isEmpty();
-  }
-
-  @Test
-  public void testToolLicenseAddedCorrectly() throws Exception {
-    scratch.file("powertools/BUILD",
-        "sh_binary(name = 'chainsaw',",
-        "          srcs = ['chainsaw.sh'],",
-        "          licenses=['restricted'],",
-        "          output_licenses=['unencumbered'])");
-
-    scratch.file("gr/BUILD",
-        "licenses(['unencumbered'])",
-        "genrule(name = 'lumberjack',",
-        "        outs=['firewood'],",
-        "        tools=['//powertools:chainsaw'],",
-        "        cmd='')",
-        "genrule(name = 'xorn',",
-        "        outs=['jewel'],",
-        "        srcs=['//powertools:chainsaw'],",
-        "        cmd='')");
-
-    ConfiguredTarget lumberjack = getConfiguredTarget("//gr:lumberjack");
-    ConfiguredTarget xorn = getConfiguredTarget("//gr:xorn");
-    Map<Label, License> lumberjackActual = Maps.filterKeys(getTransitiveLicenses(lumberjack),
-        CC_OR_JAVA_OR_SH_LABEL_FILTER);
-    Map<Label, License> xornActual = Maps.filterKeys(getTransitiveLicenses(xorn),
-        CC_OR_JAVA_OR_SH_LABEL_FILTER);
-
-    Map<Label, License> lumberjackExpected = licenses(
-        "//powertools:chainsaw", "unencumbered",
-        "//gr:lumberjack", "unencumbered");
-    Map<Label, License> xornExpected = licenses(
-        "//powertools:chainsaw", "restricted",
-        "//gr:xorn", "unencumbered");
-
-    assertSameMapEntries(lumberjackExpected, lumberjackActual);
-    assertSameMapEntries(xornExpected, xornActual);
-  }
-
-  @Test
-  public void testToolLicenseDoesNotIncludeDependencies() throws Exception {
-    scratch.file("powertools/BUILD",
-        "sh_binary(name = 'chainsaw',",
-        "          srcs = ['chainsaw.sh'],",
-        "          deps = [':gasoline'],",
-        "          licenses = ['restricted'],",
-        "          output_licenses=['unencumbered'])",
-        "sh_binary(name = 'gasoline',",
-        "          srcs = ['gasoline.sh'],",
-        "          licenses = ['notice'])");
-
-    scratch.file("gr/BUILD",
-        "licenses(['unencumbered'])",
-        "genrule(name = 'lumberjack',",
-        "        outs=['firewood'],",
-        "        tools=['//powertools:chainsaw'],",
-        "        cmd='')");
-
-    ConfiguredTarget lumberjack = getConfiguredTarget("//gr:lumberjack");
-    Map<Label, License> actual = Maps.filterKeys(getTransitiveLicenses(lumberjack),
-        CC_OR_JAVA_OR_SH_LABEL_FILTER);
-
-    Map<Label, License> expected = licenses(
-        "//powertools:chainsaw", "unencumbered",
-        "//gr:lumberjack", "unencumbered");
-
-    assertSameMapEntries(expected, actual);
-  }
-
-  @Test
-  public void testFilegroupAllowsOutputLicenseDeclaration() throws Exception {
-    scratch.file("apple/BUILD",
-        "licenses(['restricted'])",
-        "filegroup(name='apples',",
-        "          output_licenses=['unencumbered'],",
-        "          srcs=['rambo', 'granny_smith'])");
-
-    scratch.file("apfelmuss/BUILD",
-        "licenses(['unencumbered'])",
-        "genrule(name = 'apfelmuss',",
-        "        outs = ['jar'],",
-        "        tools = ['//apple:apples'],",
-        "        cmd = 'magic')");
-
-    ConfiguredTarget apfelmuss = getConfiguredTarget("//apfelmuss:apfelmuss");
-    Map<Label, License> actual = Maps.filterKeys(getTransitiveLicenses(apfelmuss),
-        CC_OR_JAVA_OR_SH_LABEL_FILTER);
-    Map<Label, License> expected = licenses(
-        "//apfelmuss:apfelmuss", "unencumbered",
-        "//apple:apples", "unencumbered");
-
-    assertSameMapEntries(expected, actual);
-  }
-
-  @Test
-  public void testEmptyToolLicenseWorks() throws Exception {
-    scratch.file("powertools/BUILD",
-        "sh_binary(name = 'chainsaw',",
-        "          srcs = ['chainsaw.sh'],",
-        "          deps = [':gasoline'],",
-        "          licenses = ['restricted'],",
-        "          output_licenses=[])",
-        "sh_binary(name = 'gasoline',",
-        "          srcs = ['gasoline.sh'],",
-        "          licenses = ['notice'])");
-
-    scratch.file("gr/BUILD",
-        "genrule(name = 'lumberjack',",
-        "        outs=['firewood'],",
-        "        tools=['//powertools:chainsaw'],",
-        "        cmd='')");
-
-    ConfiguredTarget lumberjack = getConfiguredTarget("//gr:lumberjack");
-    Map<Label, License> actual = Maps.filterKeys(getTransitiveLicenses(lumberjack),
-        CC_OR_JAVA_OR_SH_LABEL_FILTER);
-
-    Map<Label, License> expected = licenses("//powertools:chainsaw", "");
-    assertSameMapEntries(expected, actual);
-  }
-
-  @Test
-  public void testToolLicenseIncludesDependenciesIfNoOutputLicense() throws Exception {
-    scratch.file("powertools/BUILD",
-        "sh_binary(name = 'chainsaw',",
-        "          srcs = ['chainsaw.sh'],",
-        "          deps = [':gasoline'],",
-        "          licenses = ['restricted'])",
-        "sh_binary(name = 'gasoline',",
-        "          srcs = ['gasoline.sh'],",
-        "          licenses = ['notice'])");
-
-    scratch.file("gr/BUILD",
-        "licenses(['unencumbered'])",
-        "genrule(name = 'lumberjack',",
-        "        outs=['firewood'],",
-        "        tools=['//powertools:chainsaw'],",
-        "        cmd='')");
-
-    ConfiguredTarget lumberjack = getConfiguredTarget("//gr:lumberjack");
-    Map<Label, License> actual = Maps.filterKeys(getTransitiveLicenses(lumberjack),
-        CC_OR_JAVA_OR_SH_LABEL_FILTER);
-
-    Map<Label, License> expected = licenses(
-        "//powertools:chainsaw", "restricted",
-        "//powertools:gasoline", "notice",
-        "//gr:lumberjack", "unencumbered");
-
-    assertSameMapEntries(expected, actual);
-  }
-
-  @Test
-  public void testToolLicenseRecursively() throws Exception {
-    scratch.file("powertools/BUILD",
-        "licenses(['restricted'])",
-        "filegroup(name = 'chainsaw',",
-        "          srcs = ['chainsaw.sh'],",
-        "          licenses=['restricted'],",
-        "          output_licenses=['unencumbered'])",
-        "filegroup(name = 'forward',",
-        "          srcs = [':chainsaw'])");
-
-    scratch.file("gr/BUILD",
-        "licenses(['unencumbered'])",
-        "genrule(name = 'lumberjack',",
-        "        outs=['firewood'],",
-        "        tools=['//powertools:forward'],",
-        "        cmd='')");
-
-    ConfiguredTarget lumberjack = getConfiguredTarget("//gr:lumberjack");
-    Map<Label, License> lumberjackActual = Maps.filterKeys(getTransitiveLicenses(lumberjack),
-        CC_OR_JAVA_OR_SH_LABEL_FILTER);
-
-    Map<Label, License> lumberjackExpected = licenses(
-        "//powertools:chainsaw", "unencumbered",
-        "//powertools:forward", "restricted",
-        "//gr:lumberjack", "unencumbered");
-
-    assertSameMapEntries(lumberjackExpected, lumberjackActual);
-  }
-
-  @Test
-  public void testHostAttributeCanBeTool() throws Exception {
-    scratch.file(
-        "test/BUILD",
-        "genrule(",
-        "    name='gen',",
-        "    outs=['hello.txt'],",
-        "    cmd='exit 1',",
-        "    tools=['//test:compiler'],",
-        ")",
-        "sh_binary(",
-        "    name='compiler',",
-        "    srcs=['compiler.sh'],",
-        "    licenses=['restricted'],",
-        "    output_licenses=['notice'],",
-        ")");
-
-    ConfiguredTarget target = getConfiguredTarget("//test:gen");
-    Map<Label, License> actual = Maps.filterKeys(getTransitiveLicenses(target),
-        CC_OR_JAVA_OR_SH_LABEL_FILTER);
-    Map<Label, License> expected = licenses("//test:compiler", "notice");
-    assertSameMapEntries(expected, actual);
-  }
-
-  @Test
-  public void testNonHostAttributeCannotBeTool() throws Exception {
-    scratch.file("keyboardmonkeys/BUILD",
-        "genrule(name='million_monkeys',",
-        "        licenses=['restricted'],",
-        "        output_licenses=['notice'],",
-        "        outs=['source.sh'],",
-        "        cmd='type furiously on typewriters')");
-
-    scratch.file("product/BUILD",
-        "sh_binary(name='product',",
-        "          srcs=['//keyboardmonkeys:source.sh'])");
-
-    ConfiguredTarget product = getConfiguredTarget("//product:product");
-    Map<Label, License> actual = Maps.filterKeys(
-            getTransitiveLicenses(product), CC_OR_JAVA_OR_SH_LABEL_FILTER);
-
-    Map<Label, License> expected = licenses("//keyboardmonkeys:million_monkeys", "restricted");
-    assertSameMapEntries(expected, actual);
-  }
-
-  @Test
-  public void testCcToolchainLicenseOverride() throws Exception {
-    scratch.file(
-        "c/BUILD",
-        "filegroup(name = 'dynamic-runtime-libs-cherry', srcs = [], licenses = ['restricted'])",
-        "cc_toolchain(",
-        "    name = 'c',",
-        "    toolchain_identifier = 'toolchain-identifier-k8',",
-        "    output_licenses = ['notice'],",
-        "    ar_files = 'ar-cherry',",
-        "    as_files = 'as-cherry',",
-        "    compiler_files = 'compile-cherry',",
-        "    dwp_files = 'dwp-cherry',",
-        "    coverage_files = 'gcov-cherry',",
-        "    linker_files = 'link-cherry',",
-        "    strip_files = ':every-file',",
-        "    objcopy_files = 'objcopy-cherry',",
-        "    all_files = ':every-file',",
-        "    dynamic_runtime_lib = 'dynamic-runtime-libs-cherry',",
-        "    static_runtime_lib = 'static-runtime-libs-cherry')");
-    scratch.file("c/CROSSTOOL", MockCcSupport.EMPTY_CROSSTOOL);
-
-    ConfiguredTarget target = getConfiguredTarget("//c:c");
-    Map<Label, License> expected = licenses("//c:c", "notice");
-    Map<Label, License> actual = getTransitiveLicenses(target);
-    assertSameMapEntries(expected, actual);
-  }
-
-  @Test
-  public void testLicenseParsing() throws Exception {
-    License l1 = License.parseLicense(Arrays.asList("restricted",
-        "exception=//a:a"));
-    License l2 = License.parseLicense(Arrays.asList("restricted",
-        "reciprocal", "exception=//a:a"));
-    License l3 = License.parseLicense(Arrays.asList("by_exception_only",
-        "reciprocal", "exception=//a:a", "exception=//b:b"));
-    assertThat(l1.toString()).isEqualTo("[restricted] with exceptions [//a:a]");
-    assertThat(l2.toString()).isEqualTo("[restricted, reciprocal] with exceptions [//a:a]");
-    assertThat(l3.toString())
-        .isEqualTo("[by_exception_only, reciprocal] with exceptions [//a:a, //b:b]");
-  }
-
-  /**
-   * Takes a list of strings, which alternate labels with license lists, and
-   * returns a map of labels to licenses. The license strings are comma-separated
-   * strings.
-   */
-  protected static Map<Label, License> licenses(String... strings)
-      throws LicenseParsingException, LabelSyntaxException {
-    Map<Label, License> result = new HashMap<>();
-    for (int i = 0; i < strings.length; i += 2) {
-      String labelStr = strings[i];
-      String licStr = strings[i + 1];
-      Label label = Label.parseAbsolute(labelStr, ImmutableMap.of());
-      List<String> splitLicenses =
-          licStr.isEmpty() ? Arrays.<String>asList() : Arrays.asList(licStr.split(","));
-      License license = License.parseLicense(splitLicenses);
-      result.put(label, license);
-    }
-    return result;
-  }
-
-  protected static<K, V> void assertSameMapEntries(Map<K, V> expected, Map<K, V> actual) {
-    if (expected.size() != actual.size()) {
-      StringBuilder actualString = new StringBuilder();
-      for (K key : actual.keySet()) {
-        actualString.append(key + ": " + actual.get(key) + "\n");
-      }
-      int expectedSize = expected.size();
-      assertWithMessage("Expected map of size '%s' but found map of size '%s', actual value:\n%s",
-          expectedSize, actual.size(), actualString)
-          .that(actual)
-          .hasSize(expectedSize);
-    }
-    for (K key : expected.keySet()) {
-      V expectedValue = expected.get(key);
-      V actualValue = actual.get(key);
-      assertWithMessage("Key '%s'", key).that(actualValue).isNotNull();
-      assertWithMessage("Values for key '" + key + "' should match")
-          .that(actualValue)
-          .isEqualTo(expectedValue);
-    }
-  }
-
-  @Test
-  public void testDualLicensedUsesLeastRestrictive() throws Exception {
-    scratch.file("user/BUILD",
-        "sh_binary(name = 'user',",
-        "          srcs = ['user.sh'],",
-        "          deps = ['//used'])");
-
-    scratch.file("used/BUILD",
-        "licenses(['restricted', 'permissive'])",
-        "sh_library(name = 'used',",
-        "        srcs=['used.sh'])");
-
-    ConfiguredTarget used = getConfiguredTarget("//used");
-    Map<Label, License> usedActual =
-        Maps.filterKeys(getTransitiveLicenses(used), AnalysisMock.get().ccSupport().labelFilter());
-    Label usedLabel = Label.parseAbsolute("//used", ImmutableMap.of());
-    License license = usedActual.get(usedLabel);
-    LicenseCheckingModule.checkCompatibility(
-        license,
-        EnumSet.of(DistributionType.CLIENT),
-        getTarget("//user"),
-        usedLabel,
-        reporter,
-        false);
-    assertNoEvents();
-  }
-
-  /** Regression test for b/9811855. */
-  @Test
-  public void testFilegroupLicenses() throws Exception {
-    scratch.file("user/BUILD",
-        "sh_binary(name = 'user',",
-        "          srcs = ['user.sh'],",
-        "          deps = ['//used'])");
-
-    scratch.file("used/BUILD",
-        "licenses(['restricted'])",
-        "filegroup(name = 'used',",
-        "        licenses=['unencumbered'],",
-        "        srcs=['used.sh'])"); // used.sh is not 'restricted'
-
-    ConfiguredTarget used = getConfiguredTarget("//used");
-    Map<Label, License> usedActual =
-        Maps.filterKeys(getTransitiveLicenses(used), AnalysisMock.get().ccSupport().labelFilter());
-    Label usedLabel = Label.parseAbsolute("//used", ImmutableMap.of());
-    License license = usedActual.get(usedLabel);
-    LicenseCheckingModule.checkCompatibility(
-        license,
-        EnumSet.of(DistributionType.CLIENT),
-        getTarget("//user"),
-        usedLabel,
-        reporter,
-        false);
-    assertNoEvents();
-  }
-
-  /**
-   * Regression test for b/4159051: "Latest blaze release broke --check_licenses"
-   */
-  @Test
-  public void testLicenseCheckingTakesOnlyOneSelectBranch() throws Exception {
-    scratch.file("eden/BUILD",
-        "config_setting(",
-        "    name = 'config_a',",
-        "    values = {'define': 'mode=a'})",
-        "cc_library(name = 'eve',",
-        "    deps = select({",
-        "        ':config_a': ['//third_party/fruit:peach'],",
-        "        '//conditions:default': ['//third_party/fruit:apple'],",
-        "    }),",
-        "    distribs = ['client'])");
-
-    scratch.file("third_party/fruit/BUILD",
-        "cc_library(name='apple', licenses=['restricted'])",
-        "cc_library(name='peach', licenses=['unencumbered'])");
-
-    useConfiguration("--check_licenses", "--define", "mode=a");
-    ConfiguredTarget eve = getConfiguredTarget("//eden:eve");
-    Map<Label, License> eveActual =
-        Maps.filterKeys(getTransitiveLicenses(eve), AnalysisMock.get().ccSupport().labelFilter());
-    Map<Label, License> eveExpected = licenses("//third_party/fruit:peach", "unencumbered");
-    assertSameMapEntries(eveExpected, eveActual);
-    assertNoEvents();
-  }
-
-  @Test
-  public void configSettingsHaveNoLicense() throws Exception {
-    scratch.file("third_party/restricted/BUILD",
-        "licenses(['by_exception_only'])",
-        "config_setting(",
-        "    name = 'a_setting',",
-        "    values = {'define': 'mode=a'})");
-    useConfiguration("--check_licenses", "--define", "mode=a");
-    ConfiguredTarget configSetting = getConfiguredTarget("//third_party/restricted:a_setting");
-    assertThat(configSetting.getProvider(LicensesProvider.class).getTransitiveLicenses())
-        .isEmpty();
-  }
-
-  @Ignore("b/129599508")
-  @Test
-  public void testJavaToolchainOutputLicense() throws Exception {
-    scratch.file("java/a/BUILD",
-        "java_toolchain(",
-        "  name = 'toolchain',",
-        "  licenses = ['restricted'],",
-        "  output_licenses = ['unencumbered'],",
-        "  source_version = '8',",
-        "  target_version = '8',",
-        "  bootclasspath = [':bcp'],",
-        "  extclasspath = [':ecp'],",
-        "  javac = [':langtools'],",
-        "  javabuilder = ['javabuilder'],",
-        "  header_compiler = ['header_compiler'],",
-        "  singlejar = ['singlejar'],",
-        "  genclass = ['genclass'],",
-        "  ijar = ['ijar'])",
-        "java_binary(",
-        "  name = 'a',",
-        "  srcs = ['a.java'])");
-
-    useConfiguration("--java_toolchain=//java/a:toolchain", "--check_licenses");
-
-    ConfiguredTarget bin = getConfiguredTarget("//java/a:a");
-    Map<Label, License> licenses = getTransitiveLicenses(bin);
-    License toolchainLicense = licenses.get(Label.parseAbsoluteUnchecked("//java/a:toolchain"));
-    assertThat(toolchainLicense).isNotEqualTo(License.parseLicense(ImmutableList.of("restricted")));
-    assertThat(toolchainLicense).isEqualTo(License.parseLicense(ImmutableList.of("unencumbered")));
-  }
-
-  @Test
-  public void testTargetLicenseEquality() throws Exception {
-    Label label1 = Label.parseAbsolute("//foo", ImmutableMap.of());
-    Label label2 = Label.parseAbsolute("//bar", ImmutableMap.of());
-    License restricted = License.parseLicense(ImmutableList.of("restricted"));
-    License unencumbered = License.parseLicense(ImmutableList.of("unencumbered"));
-    new EqualsTester()
-        .addEqualityGroup(
-            new TargetLicense(label1, restricted),
-            new TargetLicense(label1, restricted))
-        .addEqualityGroup(
-            new TargetLicense(label2, restricted),
-            new TargetLicense(label2, restricted))
-        .addEqualityGroup(
-            new TargetLicense(label2, unencumbered),
-            new TargetLicense(label2, unencumbered))
-        .testEquals();
-  }
-
-  /** Regression fix for https://github.com/bazelbuild/bazel/issues/7194. */
-  @Test
-  public void testStarlarkLicensesAttributeCanUseUseCustomDefault() throws Exception {
-    scratch.file(
-        "foo/rules.bzl",
-        "def _myrule_impl(ctx):",
-        "    return []",
-        "",
-        "myrule = rule(",
-        "    implementation = _myrule_impl,",
-        "    attrs = {",
-        "        'licenses': attr.string(default = 'custom_licenses_default'),",
-        "    }",
-        ")");
-
-    scratch.file("foo/BUILD", "load('//foo:rules.bzl', 'myrule')", "myrule(name = 'hi')");
-
-    assertThat(RawAttributeMapper.of((Rule) getTarget("//foo:hi")).get("licenses", Type.STRING))
-        .isEqualTo("custom_licenses_default");
-    assertNoEvents();
-  }
-
-  /**
-   * Gets the licenses of all targets that are in the transitive closure of a
-   * target. The result includes this target itself.
-   *
-   * @return a map from target labels to licenses
-   */
-  protected static Map<Label, License> getTransitiveLicenses(ConfiguredTarget target) {
-    final ImmutableMap.Builder<Label, License> result = ImmutableMap.builder();
-    LicensesProvider provider = target.getProvider(LicensesProvider.class);
-    if (provider != null) {
-      for (TargetLicense targetLicense : provider.getTransitiveLicenses()) {
-        result.put(targetLicense.getLabel(), targetLicense.getLicense());
-      }
-    }
-
-    return result.build();
-  }
-}
diff --git a/src/test/java/com/google/devtools/build/lib/bazel/rules/java/BazelLicensingTests.java b/src/test/java/com/google/devtools/build/lib/bazel/rules/java/BazelLicensingTests.java
index 977753a..95851d1 100644
--- a/src/test/java/com/google/devtools/build/lib/bazel/rules/java/BazelLicensingTests.java
+++ b/src/test/java/com/google/devtools/build/lib/bazel/rules/java/BazelLicensingTests.java
@@ -14,22 +14,17 @@
 
 package com.google.devtools.build.lib.bazel.rules.java;
 
+import static com.google.common.truth.Truth.assertThat;
 
-import com.google.common.collect.Maps;
-import com.google.devtools.build.lib.analysis.ConfiguredTarget;
-import com.google.devtools.build.lib.analysis.LicensingTests;
-import com.google.devtools.build.lib.cmdline.Label;
+import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
 import com.google.devtools.build.lib.packages.License;
-import java.util.Map;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
 
-/**
- * Integration tests for {@link License}.
- */
+/** Integration tests for {@link License}. */
 @RunWith(JUnit4.class)
-public class BazelLicensingTests extends LicensingTests {
+public class BazelLicensingTests extends BuildViewTestCase {
   @Test
   public void testJavaPluginAllowsOutputLicenseDeclaration() throws Exception {
     scratch.file("ise/BUILD",
@@ -47,14 +42,7 @@
         "             srcs = ['library.java'],",
         "             plugins = ['//ise:plugin'])");
 
-    ConfiguredTarget library = getConfiguredTarget("//gsa:library");
-    Map<Label, License> actual = Maps.filterKeys(getTransitiveLicenses(library),
-        CC_OR_JAVA_OR_SH_LABEL_FILTER);
-    Map<Label, License> expected = licenses(
-        "//ise:plugin", "unencumbered",
-        "//gsa:library", "unencumbered"
-    );
-
-    assertSameMapEntries(expected, actual);
+    assertThat(getConfiguredTarget("//gsa:library")).isNotNull();
+    assertNoEvents();
   }
 }
diff --git a/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java b/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java
index 899824d..af2ee18 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java
@@ -371,39 +371,6 @@
   }
 
   @Test
-  public void testThirdPartyLicenseError() throws Exception {
-    events.setFailFast(false);
-    Path buildFile =
-        scratch.file("/third_party/foo/BUILD", "# line 1", "cc_library(name='bar')", "# line 3");
-    Package pkg =
-        packages.createPackage(
-            "third_party/foo",
-            RootedPath.toRootedPath(root, buildFile),
-            "--incompatible_disable_third_party_license_checking=false");
-    events.assertContainsError(
-        "third-party rule '//third_party/foo:bar' lacks a license "
-            + "declaration with one of the following types: "
-            + "notice, reciprocal, permissive, restricted, unencumbered, by_exception_only");
-    assertThat(pkg.containsErrors()).isTrue();
-  }
-
-  @Test
-  public void testThirdPartyLicenseExportsFileError() throws Exception {
-    events.setFailFast(false);
-    Path buildFile = scratch.file("/third_party/foo/BUILD", "exports_files(['bar'])");
-    Package pkg =
-        packages.createPackage(
-            "third_party/foo",
-            RootedPath.toRootedPath(root, buildFile),
-            "--incompatible_disable_third_party_license_checking=false");
-    events.assertContainsError(
-        "third-party file 'bar' lacks a license "
-            + "declaration with one of the following types: "
-            + "notice, reciprocal, permissive, restricted, unencumbered, by_exception_only");
-    assertThat(pkg.containsErrors()).isTrue();
-  }
-
-  @Test
   public void testDuplicateRuleIsNotAddedToPackage() throws Exception {
     events.setFailFast(false);
     Path path =
diff --git a/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java b/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java
index 91ab07b..05b615d 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java
@@ -118,7 +118,6 @@
   private static StarlarkSemanticsOptions buildRandomOptions(Random rand) throws Exception {
     return parseOptions(
         // <== Add new options here in alphabetic order ==>
-        "--check_third_party_targets_have_licenses=" + rand.nextBoolean(),
         "--experimental_build_setting_api=" + rand.nextBoolean(),
         "--experimental_cc_skylark_api_enabled_packages="
             + rand.nextDouble()
@@ -168,7 +167,6 @@
   private static StarlarkSemantics buildRandomSemantics(Random rand) {
     return StarlarkSemantics.builder()
         // <== Add new options here in alphabetic order ==>
-        .checkThirdPartyTargetsHaveLicenses(rand.nextBoolean())
         .experimentalBuildSettingApi(rand.nextBoolean())
         .experimentalCcSkylarkApiEnabledPackages(
             ImmutableList.of(String.valueOf(rand.nextDouble()), String.valueOf(rand.nextDouble())))
diff --git a/src/test/shell/bazel/license_checking_test.sh b/src/test/shell/bazel/license_checking_test.sh
index 00921be..0e63391 100755
--- a/src/test/shell/bazel/license_checking_test.sh
+++ b/src/test/shell/bazel/license_checking_test.sh
@@ -14,11 +14,12 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-# Tests Bazel's license checking semantics.
+# Third-party license checking has been removed from Bazel. See
+# https://github.com/bazelbuild/bazel/issues/7444 for details and
+# alternatives.
 #
-# This is a temporary test supporting the migration away from any license
-# checking at all. When https://github.com/bazelbuild/bazel/issues/7444 is
-# fixed this test can be deleted.
+# This test just checks that --incompatible_disable_third_party_license_checking
+# is a no-op. We can remove it when that flag is removed.
 
 # Load the test setup defined in the parent directory
 CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -64,43 +65,34 @@
 EOF
 }
 
-function test_default_mode {
+FLAG_MODES="--incompatible_disable_third_party_license_checking=true \
+  --incompatible_disable_third_party_license_checking=false"
+
+function test_license_enforcement_violation {  # Bazel should ignore this.
   create_new_workspace
   write_rules
-  bazel build --nobuild //bad:main >& $TEST_log || fail "build should succeed"
+  for flag_mode in $FLAG_MODES; do
+    bazel build --nobuild //bad:main $flag_mode \
+      >& $TEST_log || fail "build should succeed"
+  done
 }
 
-function test_license_checking {
+function test_check_licenses_flag { # Bazel should ignore this.
   create_new_workspace
   write_rules
-  bazel build --nobuild //bad:main --check_licenses --incompatible_disable_third_party_license_checking=false >& $TEST_log && fail "build shouldn't succeed"
-  expect_log "Build target '//bad:main' is not compatible with license '\[restricted\]' from target '//third_party/restrictive:lib'"
+  for flag_mode in $FLAG_MODES; do
+    bazel build --nobuild //bad:main --check_licenses $flag_mode \
+      >& $TEST_log || fail "build should succeed"
+  done
 }
 
-function test_disable_license_checking_override {
+function test_third_party_no_license { # Bazel should ignore this.
   create_new_workspace
   write_rules
-  bazel build --nobuild //bad:main --check_licenses >& $TEST_log || fail "build should succeed"
-}
-
-function test_third_party_no_license_is_checked {
-  create_new_workspace
-  write_rules
-  bazel build --nobuild --incompatible_disable_third_party_license_checking=false //third_party/missing_license:lib >& $TEST_log && fail "build shouldn't succeed"
-  expect_log "third-party rule '//third_party/missing_license:lib' lacks a license declaration"
-}
-
-function test_third_party_no_license_no_check {
-  create_new_workspace
-  write_rules
-  bazel build --nobuild //third_party/missing_license:lib --nocheck_third_party_targets_have_licenses \
-    || fail "build should succeed"
-}
-
-function test_third_party_no_license_disable_license_checking_override {
-  create_new_workspace
-  write_rules
-  bazel build --nobuild //third_party/missing_license:lib || fail "build should succeed"
+  for flag_mode in $FLAG_MODES; do
+    bazel build --nobuild  //third_party/missing_license:lib $flag_mode \
+      >& $TEST_log || fail "build should succeed"
+  done
 }
 
 run_suite "license checking tests"