bazel
bazel copied to clipboard
feat(java_library): handle output dirs in resources attribute
Passing output directories to the resources attribute of java_library now adds the contents of that output directory to the resulting jar, not just the directory itself.
Fixes #11996
Looks like this is only handling the Unix side of things. I'll look into addressing the Windows side as well when I have a moment.
I'm wondering: instead of fixing singlejar to expand directories, should we expand tree artifacts on the Bazel side [EDIT: on the Java rules side] so that the arguments to singlejar are the individual files inside? This is how most other rules handle tree artifacts.
Always happy to find better ways to do things, thanks for suggesting 👍
Before I naively send a patch, is it right to assume that all we need to do is a call to DirectoryExpander.expand() 0 for all the input files that are directories? Wondering if anyone can identify issues with the approach.
EDIT: or, more simply in this case, set expand_directories to True in relevant args passed to the action 1.
That does sound right. Directory expansion is even enabled by default.
Ok, I dug it up a bit and ended up in the native side of java rules.
It is my understanding that there is a push towards Starlark-based Java rules; given I have no experience on that side of Bazel and that the issue doesn't seem too pressing, I'll close the PR.