Skip to content

Commit 5219847

Browse files
authored
Use export_files to export the KSP JAR files (#1313)
This fixes the visibility error for "symbol-processing-cmdline.jar" in #1193. The legacy behavior of Bazel is that input source files are implicitly exported with the `default_visibility` set in the `BUILD` file. The `--incompatible_no_implicit_file_export` option disables this legacy behavior, making all input source files private by default, and the Bazel documentation recommends that files should always be exported explicitly if they are needed outside the current package: > Avoid relying on the legacy behavior. Always write an `exports_files` > declaration whenever a source file target needs non-private visibility. (see https://bazel.build/concepts/visibility#source-file-target-visibility)
1 parent 9ea77be commit 5219847

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/main/starlark/core/repositories/BUILD.com_github_google_ksp.bazel

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,16 @@
1313
# limitations under the License.
1414
package(default_visibility = ["//visibility:public"])
1515

16-
# KSP filegroup containing everything that might be needed
16+
# Collect list of all KSP files that might be needed
17+
_KSP_FILES = glob(["**"])
18+
19+
# KSP filegroup containing all KSP files to export
1720
filegroup(
1821
name = "ksp",
19-
srcs = glob(["**"]),
22+
srcs = _KSP_FILES,
2023
)
24+
25+
# If the `--incompatible_no_implicit_file_export` option is enabled, then the
26+
# individual "srcs" from the "ksp" filegroup will not be visible, so also
27+
# export them with `export_files` to ensure that they are made public.
28+
exports_files(_KSP_FILES)

0 commit comments

Comments
 (0)