admin管理员组文章数量:1404927
Given a directory structure like:
WORKSPACE
java/
BUILD
test.bash
dev/enola/io
BUILD
Resource.java
in I want to run a Lint-like test.bash
sort of script over all of my **/*.java
with this java/BUILD:
sh_test(
name = "test",
srcs = ["test.bash"],
data = glob(["**/*.java"]),
)
Running bazelisk //java:test
should test.bash
, with dev/enola/io/Resource.java in the runfiles
.
Instead, it fails with "Error in glob: glob pattern '**/*.java' didn't match anything".
I understand that this happens because there are (of course) [many other] BUILD
files within java/...
- which makes Bazel "hide" (?) their **/*.java
.
But how does one typically still somehow do this with Bazel?
Given a directory structure like:
WORKSPACE
java/
BUILD
test.bash
dev/enola/io
BUILD
Resource.java
in https://github/enola-dev/enola/pull/1202 I want to run a Lint-like test.bash
sort of script over all of my **/*.java
with this java/BUILD:
sh_test(
name = "test",
srcs = ["test.bash"],
data = glob(["**/*.java"]),
)
Running bazelisk //java:test
should test.bash
, with dev/enola/io/Resource.java in the runfiles
.
Instead, it fails with "Error in glob: glob pattern '**/*.java' didn't match anything".
I understand that this happens because there are (of course) [many other] BUILD
files within java/...
- which makes Bazel "hide" (?) their **/*.java
.
But how does one typically still somehow do this with Bazel?
Share Improve this question asked Mar 9 at 9:09 vorburgervorburger 3,93836 silver badges43 bronze badges1 Answer
Reset to default 0If you go up the dir structure, the first BUILD
file is the one "owning" the file. Whether it can be accessed from outside is regulated by the visibility, which by default is not public, hence the error. From outside, the file is simply not visible.
Now, you can change the default visibility, but maybe it would be smartest to define a filegroup instead (in the owning BUILD
file) and export that. You could also give it a speaking name.
Another question you should ask yourself is if you shouldn't merge the two BUILD
files. If they are so deeply connected, splitting them up would be questionable.
本文标签: How to use dataglob in shtest over directory containing other BUILDbazel filesStack Overflow
版权声明:本文标题:How to use data=glob in sh_test over directory containing other BUILD.bazel files? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744874372a2629825.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论