Search code examples
dependenciesbazel

How to assemble the uberjar jar with bazel?


I'd like to analyse class dependencies in a Java project build with Bazel. I use (and recommend) degraph. degraph takes a jar as an input and generates the class relationships in a graphml file.

How can I generate this monolithic jar with bazel? It seems a BUILD target will only contain the class of it sources. As a result, the better the modularisation, the less information is left for analysis.


Solution

  • The <rule_name>_deploy.jar output of java_binary will give you all the classes of the java_binary and its dependencies in one jar. See https://docs.bazel.build/versions/master/be/java.html#java_binary_implicit_outputs