Flip --incompatible_disable_third_party_license_checking.
Fixes https://github.com/bazelbuild/bazel/issues/7553. Also see https://github.com/bazelbuild/bazel/issues/7444.
RELNOTES[INC]: --incompatible_disable_third_party_license_checking` is enabled by default
PiperOrigin-RevId: 240855788
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 07a6e50..d5fa77f 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
@@ -239,7 +239,7 @@
// 3) Remove --check_third_party_targets_have_licenses.
@Option(
name = "incompatible_disable_third_party_license_checking",
- defaultValue = "false",
+ defaultValue = "true",
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
effectTags = OptionEffectTag.BUILD_FILE_SEMANTICS,
metadataTags = {
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 4a84325..cf60461 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
@@ -209,7 +209,7 @@
.incompatibleBzlDisallowLoadAfterStatement(true)
.incompatibleDepsetIsNotIterable(false)
.incompatibleDepsetUnion(false)
- .incompatibleDisableThirdPartyLicenseChecking(false)
+ .incompatibleDisableThirdPartyLicenseChecking(true)
.incompatibleDisableDeprecatedAttrParams(false)
.incompatibleDisableObjcProviderResources(false)
.incompatibleDisallowDictPlus(true)
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 f7be141..473f88db 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
@@ -277,6 +277,7 @@
@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",
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 8bd17a6..899824d 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
@@ -376,7 +376,10 @@
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));
+ 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: "
@@ -389,7 +392,10 @@
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));
+ 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: "
diff --git a/src/test/shell/bazel/license_checking_test.sh b/src/test/shell/bazel/license_checking_test.sh
index 95526f0..00921be 100755
--- a/src/test/shell/bazel/license_checking_test.sh
+++ b/src/test/shell/bazel/license_checking_test.sh
@@ -73,21 +73,20 @@
function test_license_checking {
create_new_workspace
write_rules
- bazel build --nobuild //bad:main --check_licenses >& $TEST_log && fail "build shouldn't succeed"
+ 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'"
}
function test_disable_license_checking_override {
create_new_workspace
write_rules
- bazel build --nobuild //bad:main --check_licenses --incompatible_disable_third_party_license_checking \
- >& $TEST_log || fail "build should succeed"
+ 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 //third_party/missing_license:lib >& $TEST_log && fail "build shouldn't succeed"
+ 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"
}
@@ -101,8 +100,7 @@
function test_third_party_no_license_disable_license_checking_override {
create_new_workspace
write_rules
- bazel build --nobuild //third_party/missing_license:lib --incompatible_disable_third_party_license_checking \
- || fail "build should succeed"
+ bazel build --nobuild //third_party/missing_license:lib || fail "build should succeed"
}
run_suite "license checking tests"