Skip to content

Commit a8991a6

Browse files
author
Jaden Peterson
committed
fixup! f7af4af Fixed failing Scaladoc builds
1 parent f7af4af commit a8991a6

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

scala/private/rules/scala_doc.bzl

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
"""Scaladoc support"""
22

3+
load("@io_bazel_rules_scala//scala:providers.bzl", "ScalaInfo")
34
load("@io_bazel_rules_scala//scala/private:common.bzl", "collect_plugin_paths")
45

56
ScaladocAspectInfo = provider(fields = [
67
"src_files", #depset[File]
78
"compile_jars", #depset[File]
9+
"macro_classpath", #depset[File]
810
"plugins", #depset[Target]
911
])
1012

@@ -29,23 +31,28 @@ def _scaladoc_aspect_impl(target, ctx, transitive = True):
2931
if hasattr(ctx.rule.attr, "plugins"):
3032
plugins = depset(ctx.rule.attr.plugins)
3133

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+
3240
# Sometimes we only want to generate scaladocs for a single target and not all of its
3341
# dependencies
3442
transitive_srcs = depset()
35-
transitive_compile_jars = depset()
3643
transitive_plugins = depset()
3744

3845
if transitive:
3946
for dep in ctx.rule.attr.deps:
4047
if ScaladocAspectInfo in dep:
4148
aspec_info = dep[ScaladocAspectInfo]
4249
transitive_srcs = aspec_info.src_files
43-
transitive_compile_jars = aspec_info.compile_jars
4450
transitive_plugins = aspec_info.plugins
4551

4652
return [ScaladocAspectInfo(
4753
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),
4956
plugins = depset(transitive = [plugins, transitive_plugins]),
5057
)]
5158

@@ -73,11 +80,15 @@ def _scala_doc_impl(ctx):
7380
src_files = depset(transitive = [dep[ScaladocAspectInfo].src_files for dep in ctx.attr.deps])
7481
compile_jars = depset(transitive = [dep[ScaladocAspectInfo].compile_jars for dep in ctx.attr.deps])
7582

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+
7687
# Get the 'real' paths to the plugin jars.
7788
plugins = collect_plugin_paths(depset(transitive = [dep[ScaladocAspectInfo].plugins for dep in ctx.attr.deps]).to_list())
7889

7990
# 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])
8192

8293
# Construct scaladoc args, which also include scalac args.
8394
# See `scaladoc -help` for more information.

0 commit comments

Comments
 (0)