Print tree for maven deps

85 views
Skip to first unread message

Aryeh Hillman

unread,
Jun 10, 2022, 7:00:41 PM6/10/22
to bazel-discuss
Is there a way to print a dependency tree for maven artifacts?



Alex Humesky

unread,
Jun 13, 2022, 10:11:47 PM6/13/22
to Aryeh Hillman, bazel-discuss
The general tool for this is bazel query:

So for a build like the one below, you could do:

$ bazel query --output=label_kind --noimplicit_deps --notool_deps "kind(rule, deps('//java/app:App'))"
java_binary rule //java/app:App
java_library rule //java/lib:Lib
java_library rule //java/lib2:Lib2


There might be many kinds of dependencies besides ones from maven. Getting more information than the label might require something like an aspect though, which is more complicated to use, depending on what you need and how you're getting your maven dependencies. To get a graph output, you can do --output=graph, see https://bazel.build/reference/query#display-result-graph
java/app/BUILD:
java_binary(
  name = "App",
  srcs = ["App.java"],
  deps = ["//java/lib:Lib"],
)
java/lib/BUILD:
java_library(
  name = "Lib",
  srcs = ["Lib.java"],
  deps = ["//java/lib2:Lib2"],
  visibility = ["//visibility:public"],
)
java/lib2/BUILD:
java_library(
  name = "Lib2",
  srcs = ["Lib2.java"],
  visibility = ["//visibility:public"],
)

On Fri, Jun 10, 2022 at 7:00 PM 'Aryeh Hillman' via bazel-discuss <bazel-...@googlegroups.com> wrote:
Is there a way to print a dependency tree for maven artifacts?



--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/cb25175d-3cf8-4d15-a32e-3e949612fcedn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages