Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 583946576
Change-Id: Iaa2415c704598bcd2ab959d69ce0ef186fe60019
  • Loading branch information
hvadehra authored and copybara-github committed Nov 20, 2023
1 parent e084760 commit 35e50a9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
22 changes: 22 additions & 0 deletions src/main/starlark/builtins_bzl/common/java/java_info.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,28 @@ def make_non_strict(java_info):
)
return _new_javainfo(**result)

def add_module_flags(java_info, add_exports = [], add_opens = []):
"""Returns a new JavaInfo instance with the additional add_exports/add_opens
Args:
java_info: (JavaInfo) The java info to enhance.
add_exports: ([str]) The <module>/<package>s given access to.
add_opens: ([str]) The <module>/<package>s given reflective access to.
Returns:
(JavaInfo)
"""
if not add_exports and not add_opens:
return java_info

result = _to_mutable_dict(java_info)
result.update(
module_flags_info = _create_module_flags_info(
add_exports = depset(add_exports, transitive = [java_info.module_flags_info.add_exports]),
add_opens = depset(add_opens, transitive = [java_info.module_flags_info.add_opens]),
),
)
return _new_javainfo(**result)

def set_annotation_processing(
java_info,
enabled = False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,6 @@ public void testDeps() throws Exception {

@Test
public void testModuleFlags() throws Exception {
if (!analysisMock.isThisBazel()) {
return;
}

scratch.file(
"java/jarlib2/BUILD",
"java_library(name = 'lib',",
Expand Down

0 comments on commit 35e50a9

Please sign in to comment.