Merge pull request #83 from danielmachlab/namespace

Remove the concept of license.namespace from gather_metadata_info and gather_licenses_info
diff --git a/doc_build/BUILD b/doc_build/BUILD
index 87386f1..c50e2d4 100644
--- a/doc_build/BUILD
+++ b/doc_build/BUILD
@@ -66,7 +66,7 @@
     srcs = ["%s.md" % rule for rule, _ in ORDER],
     outs = ["reference.md"],
     cmd = "$(location :merge) $(SRCS) >$@",
-    exec_tools = [":merge"],
+    tools = [":merge"],
 )
 
 [
diff --git a/rules/license.bzl b/rules/license.bzl
index e461388..032599d 100644
--- a/rules/license.bzl
+++ b/rules/license.bzl
@@ -24,6 +24,14 @@
     "license_rule_impl",
 )
 
+# Enable this if your organization requires the license text to be a file
+# checked into source control instead of, possibly, another rule.
+_require_license_text_is_a_file = False
+
+# This rule must be named "_license" for backwards compatability with older
+# or Bazel that checked that name explicitly. See
+# https://github.com/bazelbuild/bazel/commit/bbc221f60bc8c9177470529d85c3e47a5d9aaf21
+# TODO(after bazel 7.0 release): Feel free to rename the rule and move.
 _license = rule(
     implementation = license_rule_impl,
     attrs = {
@@ -34,6 +42,7 @@
                   " should be listed here. If the user can choose a single one" +
                   " of many, then only list one here.",
             providers = [LicenseKindInfo],
+            # This should be the null configuration, not the exec.
             cfg = "exec",
         ),
         "copyright_notice": attr.string(
@@ -107,11 +116,12 @@
             fail("Can not use both license_kind and license_kinds")
         license_kinds = [license_kind]
 
-    # Make sure the file exists as named in the rule. A glob expression that
-    # expands to the name of the file is not acceptable.
-    srcs = native.glob([license_text])
-    if len(srcs) != 1 or srcs[0] != license_text:
-        fail("Specified license file doesn't exist: %s" % license_text)
+    if _require_license_text_is_a_file:
+        # Make sure the file exists as named in the rule. A glob expression that
+        # expands to the name of the file is not acceptable.
+        srcs = native.glob([license_text])
+        if len(srcs) != 1 or srcs[0] != license_text:
+            fail("Specified license file doesn't exist: %s" % license_text)
 
     _license(
         name = name,
diff --git a/rules/license_impl.bzl b/rules/license_impl.bzl
index 457af13..03477c6 100644
--- a/rules/license_impl.bzl
+++ b/rules/license_impl.bzl
@@ -45,37 +45,3 @@
     )
     _debug(0, provider)
     return [provider]
-
-license_impl = rule(
-    implementation = license_rule_impl,
-    attrs = {
-        "license_kinds": attr.label_list(
-            mandatory = False,
-            doc = "License kind(s) of this license. If multiple license kinds are" +
-                  " listed in the LICENSE file, and they all apply, then all" +
-                  " should be listed here. If the user can choose a single one" +
-                  " of many, then only list one here.",
-            providers = [LicenseKindInfo],
-            cfg = "exec",
-        ),
-        "copyright_notice": attr.string(
-            doc = "Copyright notice.",
-        ),
-        "license_text": attr.label(
-            allow_single_file = True,
-            default = "LICENSE",
-            doc = "The license file.",
-        ),
-        "package_name": attr.string(
-            doc = "A human readable name identifying this package." +
-                  " This may be used to produce an index of OSS packages used by" +
-                  " an applicatation.",
-        ),
-        "namespace": attr.string(
-            doc = "A human readable name used to organize licenses into categories." +
-                  " This is used in google3 to differentiate third party licenses used" +
-                  " for compliance versus internal licenses used by SLAsan for internal" +
-                  " teams' SLAs.",
-        ),
-    },
-)
diff --git a/tests/BUILD b/tests/BUILD
index d3baafc..7f2c3ee 100644
--- a/tests/BUILD
+++ b/tests/BUILD
@@ -137,3 +137,17 @@
         ":hello_java",
     ],
 )
+
+
+license(
+    name = "license_with_generated_text",
+    license_text = ":created_license",
+    license_kinds = [":generic_notice_license"],
+)
+
+genrule(
+    name = "created_license",
+    outs = ["something.text"],
+    cmd = "echo hello >$@",
+)
+