1
1
"""Scaladoc support"""
2
2
3
+ load ("@io_bazel_rules_scala//scala:providers.bzl" , "ScalaInfo" )
3
4
load ("@io_bazel_rules_scala//scala/private:common.bzl" , "collect_plugin_paths" )
4
5
5
6
ScaladocAspectInfo = provider (fields = [
6
7
"src_files" , #depset[File]
7
8
"compile_jars" , #depset[File]
9
+ "macro_classpath" , #depset[File]
8
10
"plugins" , #depset[Target]
9
11
])
10
12
@@ -29,23 +31,28 @@ def _scaladoc_aspect_impl(target, ctx, transitive = True):
29
31
if hasattr (ctx .rule .attr , "plugins" ):
30
32
plugins = depset (ctx .rule .attr .plugins )
31
33
34
+ macro_classpath = []
35
+
36
+ for dependency in ctx .rule .attr .deps :
37
+ if ScalaInfo in dependency and dependency [ScalaInfo ].contains_macros :
38
+ macro_classpath .append (dependency [JavaInfo ].transitive_runtime_jars )
39
+
32
40
# Sometimes we only want to generate scaladocs for a single target and not all of its
33
41
# dependencies
34
42
transitive_srcs = depset ()
35
- transitive_compile_jars = depset ()
36
43
transitive_plugins = depset ()
37
44
38
45
if transitive :
39
46
for dep in ctx .rule .attr .deps :
40
47
if ScaladocAspectInfo in dep :
41
48
aspec_info = dep [ScaladocAspectInfo ]
42
49
transitive_srcs = aspec_info .src_files
43
- transitive_compile_jars = aspec_info .compile_jars
44
50
transitive_plugins = aspec_info .plugins
45
51
46
52
return [ScaladocAspectInfo (
47
53
src_files = depset (transitive = [src_files , transitive_srcs ]),
48
- compile_jars = depset (transitive = [compile_jars , transitive_compile_jars ]),
54
+ compile_jars = depset (transitive = [compile_jars ]),
55
+ macro_classpath = depset (transitive = macro_classpath ),
49
56
plugins = depset (transitive = [plugins , transitive_plugins ]),
50
57
)]
51
58
@@ -73,11 +80,15 @@ def _scala_doc_impl(ctx):
73
80
src_files = depset (transitive = [dep [ScaladocAspectInfo ].src_files for dep in ctx .attr .deps ])
74
81
compile_jars = depset (transitive = [dep [ScaladocAspectInfo ].compile_jars for dep in ctx .attr .deps ])
75
82
83
+ # See the documentation for `collect_jars` in `scala/private/common.bzl` to understand why this is prepended to the
84
+ # classpath
85
+ macro_classpath = depset (transitive = [dep [ScaladocAspectInfo ].macro_classpath for dep in ctx .attr .deps ])
86
+
76
87
# Get the 'real' paths to the plugin jars.
77
88
plugins = collect_plugin_paths (depset (transitive = [dep [ScaladocAspectInfo ].plugins for dep in ctx .attr .deps ]).to_list ())
78
89
79
90
# Construct the full classpath depset since we need to add compiler plugins too.
80
- classpath = depset (transitive = [plugins , compile_jars ])
91
+ classpath = depset (transitive = [macro_classpath , plugins , compile_jars ])
81
92
82
93
# Construct scaladoc args, which also include scalac args.
83
94
# See `scaladoc -help` for more information.
0 commit comments