Add support for add_exports/add_opens #1551
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm happy to write some tests for this, but existing tests appear to be broken in CI, and much of the functionality requires Bazel 7.0.0 to work anyway (while CI is still on Bazel 6.3).
Description
scala_binary
,scala_test
, and friends, readjava_info.module_flags_info
and include those--add-exports
and--add-opens
JVM flags in the launcher script.add_exports
andadd_opens
attributes to all rules (includingscala_import
) and propagate the flags throughJavaInfo
.JavaInfo
constructor only added this functionality in 7.0.0; see User-accessible JavaInfo constructor doesn't allow changing module_flags_info bazel#20033.Motivation
JDK 17 strongly encapsulates JDK internals, so many libraries need
--add-exports=
and--add-opens=
JVM flags to run. Bazel's Java rules already support adding those flags throughjava_library(add_opens = [...], add_exports = [...])
, and these fields are read in Bazel'sjava_binary
rule. This PR adds the same functionality to Scala rules.Fixes #1523