Closed
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_exports
andadd_opens
attributes for a third-party rule - It's impossible to merge in
runtime_deps
'add_exports
andadd_opens
, since_javainfo_init
only merges the module flags fordeps
andexports
.
A few ways to resolve this are:
- The proper fix (IMO):
- Add some options to the
JavaInfo
constructor, likeadd_exports
andadd_opens
(for "direct" rule attributes). - Change the behavior of
JavaInfo
constructor so thatadd_exports
andadd_opens
are merged forruntime_deps
in addition to justdeps
&exports
. This is IMO the right thing to do anyway, and reduces the delta betweenJavaInfo
andjava_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
JavaInfo
that simply wraps amodule_flags_info
. Then, users can calljava_common.merge([JavaInfo(…), java_common.wrap_module_flags_info(…)])
. - Loosen
java_common.merge
input validation to allowJavaInfo
-lookalikes rather than strictlyJavaInfo
objects. Then we can create a fakeJavaInfo
withmodule_flags_info
set correctly, and calljava_common.merge
to legitimize it. - Expose
_java_common_internal.wrap_java_info
to users so that they can legitimize theirJavaInfo
lookalikes.
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