Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/java/rules_jvm_external_javadoc.patch
2864 views
1
diff --git a/private/rules/javadoc.bzl b/private/rules/javadoc.bzl
2
index 9b90570..c9b6f09 100644
3
--- a/private/rules/javadoc.bzl
4
+++ b/private/rules/javadoc.bzl
5
@@ -12,10 +12,43 @@ def generate_javadoc(ctx, javadoc, source_jars, classpath, javadocopts, output):
6
arguments = [args],
7
)
8
9
+def _get_prefix_strings(third_party_prefixes):
10
+ path_prefixes = []
11
+ for prefix in third_party_prefixes:
12
+ if prefix.find(":") != -1:
13
+ fail("Target prefixes may only contain paths, not specific targets: %s" % prefix)
14
+
15
+ if prefix.startswith("@"):
16
+ if len(prefix) > 1:
17
+ path_prefixes.append("external/%s" % prefix[1:].replace("//", "/"))
18
+ else:
19
+ # Allow all external dependencies to be ignored
20
+ path_prefixes.append("external/")
21
+ elif prefix.startswith("//"):
22
+ if len(prefix) < 3:
23
+ fail("Prefixes for targets within this workspace must contain a path")
24
+ path_prefixes.append(prefix[2:])
25
+
26
+ # Now we have the prefixes, ensure that they do not end with a slash
27
+ return [path[:-1] if path.endswith("/") else path for path in path_prefixes]
28
+
29
+def _path_match(file, prefixes):
30
+ short_path = file.dirname[len(file.root.path) + 1:]
31
+
32
+ for prefix in prefixes:
33
+ if short_path.startswith(prefix):
34
+ return True
35
+ return False
36
+
37
def _javadoc_impl(ctx):
38
+ path_prefixes = _get_prefix_strings(ctx.attr.third_party_prefixes)
39
sources = []
40
+
41
for dep in ctx.attr.deps:
42
- sources.extend(dep[JavaInfo].source_jars)
43
+ dep_srcs = dep[JavaInfo].transitive_source_jars.to_list() if ctx.attr.transitive else dep[JavaInfo].source_jars
44
+ for jar in dep_srcs:
45
+ if not _path_match(jar, path_prefixes):
46
+ sources.append(jar)
47
48
jar_file = ctx.actions.declare_file("%s.jar" % ctx.attr.name)
49
50
@@ -41,13 +74,23 @@ javadoc = rule(
51
doc = """The java libraries to generate javadocs for.
52
53
The source jars of each dep will be used to generate the javadocs.
54
- Currently docs for transitive dependencies are not generated.
55
+ By default docs for transitive dependencies are not generated.
56
""",
57
mandatory = True,
58
providers = [
59
[JavaInfo],
60
],
61
),
62
+ "transitive": attr.bool(
63
+ doc = "Whether to generate docs for transitive dependencies too.",
64
+ default = False,
65
+ ),
66
+ "third_party_prefixes": attr.string_list(
67
+ doc = """Label prefixes to exclude from javadoc generation. This designed
68
+ to allow merging of all first party javadocs into a single jar whilst not
69
+ including any javadocs for third party packages the code may depend on.""",
70
+ default = ["@maven//"],
71
+ ),
72
"javadocopts": attr.string_list(
73
doc = """javadoc options.
74
Note sources and classpath are derived from the deps. Any additional
75
76