Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create sources jars for java_library in bazel

Tags:

bazel

As part of our efforts to create a bazel-maven transition interop tool (that creates maven sized jars from more granular sized bazel jars) there is a need to create sources jars.

For java_binary targets there is a mechanism to create it using -src.jar suffix

e.g., for a java_binary target called foo, run bazel build //:foo-src.jar

But, using the same mechanism for java_library target named bar I get: ERROR: no such target '//:bar-src.jar': target 'bar-src.jar' not declared in package '' (did you mean 'libbar-src.jar'?) defined by /Users/.../java_project/BUILD.

Is there a another mechanism for java_library?

like image 379
Natan Avatar asked Oct 15 '25 22:10

Natan


1 Answers

As indicated by the error, the source target is called //:libbar-src.jar (with the lib prefix). See the list of outputs of java_library for reference.

like image 92
Damien Martin-Guillerez Avatar answered Oct 19 '25 09:10

Damien Martin-Guillerez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!