bazelbuild / buildtools

A bazel BUILD file formatter and editor
Apache License 2.0
1.03k stars 417 forks source link

Can unused_deps find and remove maven targets? #1175

Open mtheos opened 1 year ago

mtheos commented 1 year ago

Hi team 👋

I looked at the unused_deps tool today to see how it works and if it's possible to make it remove maven targets in addition to repo ones.

I saw that the tool uses the target-label from the header-jar manifest to match a jar with the repo target. Since there are no header-jars for maven dependencies they're ignored by the tool.

It's possible to derive the name of the maven target from the path and use that to include maven targets in the output. Is there a reason this hasn't been done before (is it more difficult than I expect / am I going down a rabbit hole?), or was it just never looked at?

I also looked at parsing the jar paths in the _javac_params aspect from unused_deps.bzl but I assume you prefer to do the heavy lifting in Go over Starlark (lmk if I'm mistaken).

I have a POC that works for our cases and I'd be happy to clean it up and open a PR to discuss if you're open to the change.

Thanks

razfriman commented 1 year ago

Bump!