Skip to content

Commit 47c9efd

Browse files
committed
Use new style providers in twitter_scrooge
This addresses bazel-contrib#564 tl;dr: In order to support thrift resolution in IJ, we had to use old-style providers to return the metadata in a shape that IJ understood. Since bazel 0.17, java_common.merge has been changed to support using new-style providers. This uses new-style providers and gets rid of the previous hack, but note that this means this change *isn't compatible with bazel < 0.17*
1 parent 2663c4a commit 47c9efd

File tree

1 file changed

+7
-32
lines changed

1 file changed

+7
-32
lines changed

twitter_scrooge/twitter_scrooge.bzl

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ ScroogeAspectInfo = provider(fields = [
127127
"thrift_info",
128128
"src_jars",
129129
"output_files",
130-
"transitive_output_files",
131130
"java_info",
132131
])
133132

@@ -329,16 +328,14 @@ def _scrooge_aspect_impl(target, ctx):
329328
outs = depset()
330329
java_info = _empty_java_info(deps, imps)
331330

332-
transitive_outs = depset(
333-
outs.to_list(),
334-
transitive = [d[ScroogeAspectInfo].output_files for d in ctx.rule.attr.deps]
331+
java_info = java_common.merge(
332+
[java_info] + [d[ScroogeAspectInfo].java_info for d in ctx.rule.attr.deps]
335333
)
336334

337335
return [
338336
ScroogeAspectInfo(
339337
src_jars = src_jars,
340338
output_files = outs,
341-
transitive_output_files = transitive_outs,
342339
thrift_info = transitive_ti,
343340
java_info = java_info,
344341
),
@@ -394,16 +391,11 @@ def _scrooge_scala_library_impl(ctx):
394391
else:
395392
all_java = aspect_info.java_info
396393

397-
# TODO: Remove `scala` field once JavaInfo supports multiple
398-
# output jars. https://github.com/bazelbuild/rules_scala/issues/564
399-
return struct(
400-
scala = _create_scala_struct(ctx), # For IntelliJ support
401-
providers = [
402-
all_java,
403-
ScroogeInfo(aspect_info = aspect_info),
404-
DefaultInfo(files = aspect_info.output_files),
405-
],
406-
)
394+
return [
395+
all_java,
396+
ScroogeInfo(aspect_info = aspect_info),
397+
DefaultInfo(files = aspect_info.output_files),
398+
]
407399

408400
scrooge_scala_library = rule(
409401
implementation = _scrooge_scala_library_impl,
@@ -414,23 +406,6 @@ scrooge_scala_library = rule(
414406
provides = [DefaultInfo, ScroogeInfo, JavaInfo],
415407
)
416408

417-
def _create_scala_struct(ctx):
418-
"""Create a scala provider in the shape expected by the IntelliJ bazel plugin."""
419-
output_jars = []
420-
421-
for dep in ctx.attr.deps:
422-
for j in dep[ScroogeAspectInfo].transitive_output_files:
423-
output_jars.append(
424-
struct(
425-
class_jar = j,
426-
ijar = None,
427-
source_jar = None,
428-
source_jars = [],
429-
),
430-
)
431-
432-
return struct(outputs = struct(jars = output_jars))
433-
434409
def _scrooge_scala_import_impl(ctx):
435410
scala_jars = depset(ctx.files.scala_jars)
436411
jars_ji = java_common.create_provider(

0 commit comments

Comments
 (0)