1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
"""Test cases for license rules."""
load("@rules_license//rules:compliance.bzl", "check_license")
load("@rules_license//rules:license.bzl", "license")
load("@rules_license//rules:license_kind.bzl", "license_kind")
load("@rules_license//tools:test_helpers.bzl", "golden_test")
package(default_applicable_licenses = [":license"])
licenses(["notice"])
# license_kind rules generally appear in a central location per workspace. They
# are intermingled with normal target build rules
license_kind(
name = "generic_notice_license",
conditions = [
"notice",
],
)
license_kind(
name = "generic_restricted_license",
conditions = [
"restricted",
],
)
# The default license for an entire package is typically named "license".
license(
name = "license",
package_name = "A test case package",
# Note the UTF-8 encoded copyright symbol.
copyright_notice = "Copyright © 2019 Uncle Toasty",
license_kinds = [":generic_notice_license"],
# Note. This need not be precise. If a downloader creates the license
# clause for you, then it should use the absolute download URL.
package_url = "http://github.com/bazelbuild/rules_license",
package_version = "0.0.4",
)
license(
name = "license_for_extra_feature",
package_name = "A test case package",
license = "LICENSE.extra",
license_kinds = [":generic_restricted_license"],
)
cc_binary(
name = "hello",
srcs = ["hello.cc"],
deps = [
":c_bar",
],
)
cc_library(
name = "c_bar",
srcs = ["bar.cc"],
)
java_binary(
name = "hello_java",
srcs = ["Hello.java"],
# Add an addition license to this target, beyond what my deps have.
applicable_licenses = [
":license_for_extra_feature",
],
main_class = "Hello",
deps = [
":j_bar",
],
)
java_library(
name = "j_bar",
srcs = ["Bar.java"],
)
check_license(
name = "check_cc_app",
check_conditions = False,
copyright_notices = "hello_cc_copyrights.txt",
license_texts = "hello_cc_licenses.txt",
report = "hello_cc_report",
deps = [
":hello",
],
)
check_license(
name = "check_java_app",
check_conditions = False,
copyright_notices = "hello_java_copyrights.txt",
license_texts = "hello_java_licenses.txt",
report = "hello_java_report",
deps = [
":hello_java",
],
)
golden_test(
name = "verify_cc_app_test",
golden = "hello_cc_copyrights.golden",
subject = ":hello_cc_copyrights.txt",
)
golden_test(
name = "verify_java_app_test",
golden = "hello_java_copyrights.golden",
subject = ":hello_java_copyrights.txt",
)
|