Add `default_applicable_license` and remove obsolete `licenses()` in all BUILD files (#504)

This commit is contained in:
Alexandre Rostovtsev 2024-05-01 17:24:18 -04:00 committed by GitHub
parent 16bf90d4ae
commit a16ebb4dca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 104 additions and 31 deletions

12
BUILD
View File

@ -1,8 +1,16 @@
load("@rules_license//rules:license.bzl", "license")
load("//:bzl_library.bzl", "bzl_library")
licenses(["notice"])
package(
default_applicable_licenses = ["//:license"],
default_visibility = ["//visibility:public"],
)
package(default_visibility = ["//visibility:public"])
license(
name = "license",
package_name = "bazelbuild/bazel_skylib",
license_kinds = ["@rules_license//licenses/spdx:Apache-2.0"],
)
# buildifier: disable=skylark-comment
# gazelle:exclude skylark_library.bzl

View File

@ -11,6 +11,7 @@ register_toolchains(
)
bazel_dep(name = "platforms", version = "0.0.4")
bazel_dep(name = "rules_license", version = "0.0.7")
### INTERNAL ONLY - lines after this are not included in the release packaging.

View File

@ -4,6 +4,7 @@ load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("distribution.bzl", "remove_internal_only")
package(
default_applicable_licenses = ["//:license"],
default_visibility = ["//visibility:private"],
)

View File

@ -1,6 +1,6 @@
load("//docs/private:stardoc_with_diff_test.bzl", "stardoc_with_diff_test", "update_docs")
licenses(["notice"])
package(default_applicable_licenses = ["//:license"])
stardoc_with_diff_test(
name = "analysis_test",

View File

@ -1 +1,3 @@
# No targets in this package
# This package only contains source targets
package(default_applicable_licenses = ["//:license"])

View File

@ -1,4 +1,13 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@rules_license//rules:license.bzl", "license")
package(default_applicable_licenses = ["@bazel_skylib//:license"])
license(
name = "license",
package_name = "bazelbuild/bazel_skylib_gazelle_module",
license_kinds = ["@rules_license//licenses/spdx:Apache-2.0"],
)
exports_files(["WORKSPACE.bzlmod"])

View File

@ -6,7 +6,8 @@ module(
)
# Keep in sync with @bazel_skylib//:MODULE.bazel and @bazel_skylib//:version.bzl
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "bazel_skylib", version = "1.6.1")
bazel_dep(name = "rules_license", version = "0.0.7")
bazel_dep(name = "gazelle", version = "0.29.0", repo_name = "bazel_gazelle")
bazel_dep(name = "rules_go", version = "0.41.0", repo_name = "io_bazel_rules_go")

View File

@ -1,6 +1,8 @@
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
package(default_applicable_licenses = ["//:license"])
# gazelle:exclude testdata
go_library(

View File

@ -22,6 +22,16 @@ def bazel_skylib_gazelle_plugin_workspace():
"""Loads dependencies required to use skylib's gazelle plugin"""
bazel_skylib_workspace()
maybe(
http_archive,
name = "rules_license",
sha256 = "4531deccb913639c30e5c7512a054d5d875698daeb75d8cf90f284375fe7c360",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz",
"https://github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz",
],
)
maybe(
http_archive,
name = "io_bazel_rules_go",

View File

@ -1,8 +1,9 @@
load("//:bzl_library.bzl", "bzl_library")
licenses(["notice"])
package(default_visibility = ["//visibility:public"])
package(
default_applicable_licenses = ["//:license"],
default_visibility = ["//visibility:public"],
)
# export bzl files for the documentation
exports_files(

View File

@ -1,8 +1,9 @@
load("//:bzl_library.bzl", "bzl_library")
licenses(["notice"])
package(default_visibility = ["//visibility:public"])
package(
default_applicable_licenses = ["//:license"],
default_visibility = ["//visibility:public"],
)
bzl_library(
name = "analysis_test",

View File

@ -1,6 +1,6 @@
load("//:bzl_library.bzl", "bzl_library")
licenses(["notice"])
package(default_applicable_licenses = ["//:license"])
bzl_library(
name = "copy_common",

View File

@ -15,7 +15,10 @@ load(":types_tests.bzl", "types_test_suite")
load(":unittest_tests.bzl", "unittest_passing_tests_suite")
load(":versions_tests.bzl", "versions_test_suite")
licenses(["notice"])
package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
)
exports_files(
["unittest.bash"],

View File

@ -1,6 +1,11 @@
load("//:bzl_library.bzl", "bzl_library")
load(":bzl_library_test.bzl", "bzl_library_test")
package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
)
filegroup(
name = "a",
srcs = ["testdata/a.bzl"],

View File

@ -1,8 +1,9 @@
load("//rules:common_settings.bzl", "int_flag", "string_flag")
licenses(["notice"])
package(default_testonly = 1)
package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
)
int_flag(
name = "my_int_flag",

View File

@ -3,9 +3,10 @@
load("//rules:copy_directory.bzl", "copy_directory")
load(":empty_directory.bzl", "empty_directory")
licenses(["notice"])
package(default_testonly = 1)
package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
)
# Copy of directory containing files a and b, and a subdir containing c
copy_directory(

View File

@ -33,9 +33,10 @@
load("//rules:copy_file.bzl", "copy_file")
licenses(["notice"])
package(default_testonly = 1)
package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
)
sh_test(
name = "copy_file_tests",

View File

@ -2,9 +2,10 @@
load("//rules:diff_test.bzl", "diff_test")
licenses(["notice"])
package(default_testonly = 1)
package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
)
sh_test(
name = "diff_test_tests",

View File

@ -16,6 +16,11 @@
load("//rules:expand_template.bzl", "expand_template")
package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
)
expand_template(
name = "filled_template",
out = "foo/test.yaml",

View File

@ -2,6 +2,7 @@ load("//rules:copy_file.bzl", "copy_file")
load("//rules:native_binary.bzl", "native_binary", "native_test")
package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
default_visibility = ["//visibility:private"],
)

View File

@ -3,6 +3,7 @@ load("//rules:run_binary.bzl", "run_binary")
load("//rules:write_file.bzl", "write_file")
package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
default_visibility = ["//visibility:private"],
)

View File

@ -1,7 +1,10 @@
load("//rules:diff_test.bzl", "diff_test")
load("//rules:select_file.bzl", "select_file")
licenses(["notice"])
package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
)
filegroup(
name = "fg",

View File

@ -79,7 +79,10 @@ EOF
ln -sf "$(rlocation $TEST_WORKSPACE/lib/unittest.bzl)" lib/unittest.bzl
mkdir -p toolchains/unittest
ln -sf "$(rlocation $TEST_WORKSPACE/toolchains/unittest/BUILD)" toolchains/unittest/BUILD
# Remove `package(default_applicable_license = ...)` line to avoid depending on rules_license inside this test
sed -e '/package(default_applicable_licenses = .*)/d' \
"$(rlocation $TEST_WORKSPACE/toolchains/unittest/BUILD)" \
> toolchains/unittest/BUILD
# Create test files.
mkdir -p testdir

View File

@ -35,9 +35,10 @@
load("//rules:diff_test.bzl", "diff_test")
load("//rules:write_file.bzl", "write_file")
licenses(["notice"])
package(default_testonly = 1)
package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
)
sh_test(
name = "write_file_tests",

View File

@ -1,6 +1,6 @@
load("//lib:unittest.bzl", "TOOLCHAIN_TYPE", "unittest_toolchain")
licenses(["notice"])
package(default_applicable_licenses = ["//:license"])
toolchain_type(
name = "toolchain_type",

View File

@ -15,7 +15,18 @@
"""Dependency registration helpers for repositories which need to load bazel-skylib."""
load("@bazel_skylib//lib:unittest.bzl", "register_unittest_toolchains")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
def bazel_skylib_workspace():
"""Registers toolchains and declares repository dependencies of the bazel_skylib repository."""
maybe(
http_archive,
name = "rules_license",
sha256 = "4531deccb913639c30e5c7512a054d5d875698daeb75d8cf90f284375fe7c360",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz",
"https://github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz",
],
)
register_unittest_toolchains()