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"],
)