Natan
Natan

Reputation: 2054

How to create sources jars for java_library in 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?

Upvotes: 4

Views: 1402

Answers (1)

Damien Martin-Guillerez
Damien Martin-Guillerez

Reputation: 2370

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.

Upvotes: 6

Related Questions