Make Java runfiles library repo mapping aware#16549
Make Java runfiles library repo mapping aware#16549fmeum wants to merge 9 commits intobazelbuild:masterfrom
Conversation
|
Hey, one more question. I noticed a pattern in the repo, that works and is slightly less invasive: https://cs.opensource.google/bazel/bazel/+/master:src/test/java/com/google/devtools/build/android/dexer/DexFileSplitterTest.java;l=57-60;drc=0a23d46976c3fc999d44fbd1e37732ec2442d485 What do you think about that? Could we ask users to use canonical repo names? The benefit I see is, that we wouldn't need repo_mapping, changes to Runfiles library or an annotation (in pr #16534). The mechanism is neat, but needs some more effort from the user. Perhaps it's possible to improve on it? The drawback is, that if you go forward with repo_mappings and annotation, you probably cancel out this mechanism. |
|
@comius This pattern is just great for binaries and tests with small scope, which is exactly why I'm pushing so hard to get #16428 in without a flag: It would already be useful in today's WORKSPACE world and would be required with Bzlmod as the "hardcoded repo name + It doesn't work well for binaries with more data deps and in particular doesn't work well with libraries that bring in data deps since the top-level binary would need to pass in all their paths explicitly, which gets infeasible pretty quickly. |
This is not a problem: The |
True. |
Ah, thanks for the answer! |
caddaf8 to
ac3198c
Compare
ac3198c to
07a1ffc
Compare
I did a quick review and the last three commits all look reasonable. One more thing you should consider is making preload() method a lazy initializer / preloaded runfiles a singleton. Singleton pattern is usually avoided at all costs, however it looks at the moment Bazel's design forces you into a single global instance. Making it a singleton might prevent involuntary duplication by the user. Libraries using runfiles might be coming from a different repository, that could follow a different philosophy and there might be no way of passing the Runfiles object down to those libraries. |
|
@comius I can make Should I use |
Sounds ok.
I think with or without it should be fine. Without it the could would be simpler and with it you can arguably save some memory in some cases. I can't say there's a strong case for one or the other decision. |
d9f7057 to
fcf552b
Compare
|
@comius I went with a softly cached singleton instance in a new commit. |
fcf552b to
9498de7
Compare
|
@bazel-io flag |
|
@bazel-io fork 6.0.0 |
9498de7 to
86a77b7
Compare
|
Rebased on master, but remains stacked on #16534. |
86a77b7 to
b93bc8d
Compare
|
Rebased and no longer stacked. |
Work towards bazelbuild#16124 Closes bazelbuild#16549. PiperOrigin-RevId: 487797147 Change-Id: Ic8e643898b145b7ea1e72f4a0deedfd4dfd50242
Work towards #16124