-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Closed
Labels
Description
Description of the feature request:
The user-accessible JavaInfo constructor runs _javainfo_init, which does not allow customizing module_flags_info. This means that it's impossible to replicate some of the semantics of java_info_for_compilation that would be useful for third party rulesets (like rules_scala), like:
- It's impossible to make
add_exportsandadd_opensattributes for a third-party rule - It's impossible to merge in
runtime_deps'add_exportsandadd_opens, since_javainfo_initonly merges the module flags fordepsandexports.
A few ways to resolve this are:
- The proper fix (IMO):
- Add some options to the
JavaInfoconstructor, likeadd_exportsandadd_opens(for "direct" rule attributes). - Change the behavior of
JavaInfoconstructor so thatadd_exportsandadd_opensare merged forruntime_depsin addition to justdeps&exports. This is IMO the right thing to do anyway, and reduces the delta betweenJavaInfoandjava_info_for_compilation, though it changes some user-visible behavior and probably requires an--[no]incompatible_flag.
- Add some options to the
- Provide a factory function for
JavaInfothat simply wraps amodule_flags_info. Then, users can calljava_common.merge([JavaInfo(…), java_common.wrap_module_flags_info(…)]). - Loosen
java_common.mergeinput validation to allowJavaInfo-lookalikes rather than strictlyJavaInfoobjects. Then we can create a fakeJavaInfowithmodule_flags_infoset correctly, and calljava_common.mergeto legitimize it. - Expose
_java_common_internal.wrap_java_infoto users so that they can legitimize theirJavaInfolookalikes.
I'm happy to provide a patch. Please let me know which approach seems the most reasonable.
Which category does this issue belong to?
Java Rules, Rules API
What underlying problem are you trying to solve with this feature?
No response
Which operating system are you running Bazel on?
No response
What is the output of bazel info release?
No response
If bazel info release returns development version or (@non-git), tell us how you built Bazel.
No response
What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?
No response
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
Reactions are currently unavailable