-
-
Notifications
You must be signed in to change notification settings - Fork 287
Fix Intellij Bazel Plugin support for scrooge_scala_library rule #562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,15 +185,13 @@ def _compile_scala(ctx, label, output, scrooge_jar, deps_java_info, | |
expect_java_output = False, | ||
scalac_jvm_flags = []) | ||
|
||
return java_common.create_provider( | ||
use_ijar = False, | ||
source_jars = [scrooge_jar], | ||
compile_time_jars = depset( | ||
[output], transitive = [merged_deps.compile_jars]), | ||
transitive_compile_time_jars = depset( | ||
[output], transitive = [merged_deps.transitive_compile_time_jars]), | ||
transitive_runtime_jars = depset( | ||
[output], transitive = [merged_deps.transitive_runtime_jars])) | ||
return JavaInfo( | ||
source_jar = scrooge_jar, | ||
deps = deps_java_info + implicit_deps, | ||
runtime_deps = deps_java_info + implicit_deps, | ||
exports = deps_java_info + implicit_deps, | ||
output_jar = output, | ||
compile_jar = output) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just making sure you intentionally don’t want ijar here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See this comment on line 164:
|
||
|
||
def _empty_java_info(deps_java_info, implicit_deps): | ||
merged_deps = java_common.merge(deps_java_info + implicit_deps) | ||
|
@@ -300,10 +298,16 @@ def _scrooge_scala_library_impl(ctx): | |
all_java = java_common.merge(exports + [aspect_info.java_info]) | ||
else: | ||
all_java = aspect_info.java_info | ||
return [ | ||
DefaultInfo(files = aspect_info.output_files), | ||
ScroogeInfo(aspect_info = aspect_info), all_java | ||
] | ||
|
||
# TODO: Remove `scala` field once JavaInfo supports multiple | ||
# output jars. https://github.com/bazelbuild/rules_scala/issues/564 | ||
return struct( | ||
scala = _create_scala_struct(ctx), # For IntelliJ support | ||
providers = [ | ||
all_java, | ||
ScroogeInfo(aspect_info = aspect_info), | ||
DefaultInfo(files = aspect_info.output_files) | ||
]) | ||
|
||
scrooge_scala_library = rule( | ||
implementation = _scrooge_scala_library_impl, | ||
|
@@ -314,6 +318,21 @@ scrooge_scala_library = rule( | |
provides = [DefaultInfo, ScroogeInfo, JavaInfo], | ||
) | ||
|
||
def _create_scala_struct(ctx): | ||
"""Create a scala provider in the shape expected by the IntelliJ bazel plugin.""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we are transitively putting things here? This part is confusing to me because it seems some jars will end up in many targets. Why doesn't this work to just put There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's transitive in the sense that it pulls jars from the scrooge_scala_library's deps. Is that what you mean? I'm not sure I understand the question. Let me explain my understanding and see if that clears it up or if I'm mistaken: My understanding is, suppose we have some scrooge target:
The aspect will traverse the deps, call scrooge against each target's sources, produce a jar for each, and store a reference to those jars in each dep's This function gathers up all those jars by iterating through It also gets the jars for |
||
output_jars = [] | ||
|
||
for dep in ctx.attr.deps: | ||
for j in dep[ScroogeAspectInfo].java_info.outputs.jars: | ||
output_jars.append( | ||
struct( | ||
class_jar = j.class_jar, | ||
ijar = None, | ||
source_jar = None, | ||
source_jars = [])) | ||
|
||
return struct(outputs = struct(jars = output_jars)) | ||
|
||
def _scrooge_scala_import_impl(ctx): | ||
scala_jars = depset(ctx.files.scala_jars) | ||
jars_ji = java_common.create_provider( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I ask why do you export everything? Doesn’t sound like the right behavior (though I agree that it looks like the existing code does the same)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That does seem odd. @johnynek: do you know if this is necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johnynek wdyt? As far as I'm concerned we can merge as is but just want to make sure this is indeed what you need
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a comment to the ticket (schemas don't have implementations that users control, so the data types are generally needed by downstream, more-over if any transitive schema changes you will need a recomputation in most cases).
We can revisit if this intuition is wrong.