This was solved by moving to bazel. It's a bit more verbose and resource heavy, but the language is sane and how you structure your build code makes a lot of sense
Good luck, from my experience with bazel it may go smooth if you have someone who can into bazel to help you, and you create the project from scratch to then maintain small changes. Then there was my attempt to migrate an existing Java project to bazel without external help that failed hard (maybe the situation improved from 2021).
Not sure about java, but I migrated a fairly big c++ project knowing only the basics of Bazel. Disclaimer: I know the codebase extremely well and we don't have any third party dependencies and the code is c++ and some python generators, validators, etc (which fits the bill for Bazel perfectly)
What I found super hard were toolchains. It's very verbose to define a toolchain
I have legitimately never met a single person in real life who has anything positive to say about bazel, and I assume it it because they have all killed themselves.