@@ -63,11 +63,10 @@ def _process_with_ijars_if_needed(jars, ctx):
6363
6464 return file_dict
6565
66- def _check_export_error (ctx , exports ):
67- not_in_allowlist = hasattr (ctx .attr , "_allowlist_java_import_exports" ) and not getattr (ctx .attr , "_allowlist_java_import_exports" )[PackageSpecificationInfo ].contains (ctx .label )
66+ def _check_export_error (ctx , exports , permit_exports ):
6867 disallow_java_import_exports = ctx .fragments .java .disallow_java_import_exports ()
6968
70- if len (exports ) != 0 and (disallow_java_import_exports or not_in_allowlist ):
69+ if len (exports ) != 0 and (disallow_java_import_exports or not permit_exports ):
7170 fail ("java_import.exports is no longer supported; use java_import.deps instead" )
7271
7372def _check_empty_jars_error (ctx , jars ):
@@ -84,7 +83,9 @@ def bazel_java_import_rule(
8483 neverlink = False ,
8584 proguard_specs = [],
8685 add_exports = [],
87- add_opens = []):
86+ add_opens = [],
87+ permit_exports = True ,
88+ skip_incomplete_deps_check = True ):
8889 """Implements java_import.
8990
9091 This rule allows the use of precompiled .jar files as libraries in other Java rules.
@@ -100,22 +101,23 @@ def bazel_java_import_rule(
100101 proguard_specs: (list[File]) Files to be used as Proguard specification.
101102 add_exports: (list[str]) Allow this library to access the given <module>/<package>.
102103 add_opens: (list[str]) Allow this library to reflectively access the given <module>/<package>.
104+ permit_exports: (bool) Allow using exports
105+ skip_incomplete_deps_check: (bool) If this target is allowed to have incomplete deps
103106
104107 Returns:
105108 (list[provider]) A list containing DefaultInfo, JavaInfo,
106109 OutputGroupsInfo, ProguardSpecProvider providers.
107110 """
108111
109112 _check_empty_jars_error (ctx , jars )
110- _check_export_error (ctx , exports )
113+ _check_export_error (ctx , exports , permit_exports )
111114
112115 collected_jars = _collect_jars (ctx , jars )
113116 all_deps = _filter_provider (JavaInfo , deps , exports )
114117
115118 jdeps_artifact = None
116119 merged_java_info = java_common .merge (all_deps )
117- not_in_allowlist = hasattr (ctx .attr , "_allowlist_java_import_deps_checking" ) and not ctx .attr ._allowlist_java_import_deps_checking [PackageSpecificationInfo ].contains (ctx .label )
118- if not_in_allowlist and "incomplete-deps" not in ctx .attr .tags :
120+ if not skip_incomplete_deps_check and "incomplete-deps" not in ctx .attr .tags :
119121 jdeps_artifact = import_deps_check (
120122 ctx ,
121123 collected_jars ,
0 commit comments