I have an integration test target which uses runfiles from two different targets:
java_test(
name = "test",
srcs = ["Test.java"],
data = ["//package:resource1", "//package:resource2"],
...
)
The first one is a filegroup:
filegroup(
name = "resource1",
srcs = glob(
["test-resources/sample-repo/**"],
exclude_directories = 0,
),
visibility = ["//visibility:public"],
)
and the second one is a genrule:
genrule(
name = "resource2",
srcs = [],
outs = [
"test-resources/sample-repo/file1",
"test-resources/sample-repo/file2",
],
cmd = "$(location //package:tool) -d $(RULEDIR)/test-resources/sample-repo",
tools = ["//package:tool"],
visibility = ["//visibility:public"],
)
The test requires the files obtained from both the filegroup and the genrule to be placed in a single directory (let's say: test-resources/sample-repo
).
However, apparently it is not possible to achieve that using the method described above:
WARNING: [path to my repo]/BUILD:8:17: runfiles symlink test/test-resources/sample-repo/file1 -> bazel-out/k8-fastbuild/bin/test/test-resources/sample-repo/file1 obscured by test/test-resources/sample-repo -> test/test-resources/sample-repo
WARNING: [path to my repo]/BUILD:8:17: runfiles symlink test/test-resources/sample-repo/file2 -> bazel-out/k8-fastbuild/bin/test/test-resources/sample-repo/file2 obscured by test/test-resources/sample-repo -> test/test-resources/sample-repo
My last resort would be copying the files at runtime, but I'd rather avoid it. Is there any way to gather runfiles from multiple targets in a single directory?