bazel icon indicating copy to clipboard operation
bazel copied to clipboard

feat(java_library): handle output dirs in resources attribute

Open sitaktif opened this issue 1 year ago • 3 comments

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

sitaktif avatar May 03 '24 14:05 sitaktif

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.

sitaktif avatar May 29 '24 09:05 sitaktif

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.

tjgq avatar May 29 '24 11:05 tjgq

Always happy to find better ways to do things, thanks for suggesting 👍

sitaktif avatar May 29 '24 12:05 sitaktif

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.

sitaktif avatar Sep 10 '24 12:09 sitaktif

That does sound right. Directory expansion is even enabled by default.

fmeum avatar Sep 10 '24 13:09 fmeum

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.

sitaktif avatar Sep 11 '24 09:09 sitaktif