It’s hard to debug without knowing the code, and not having build scans certainly makes it harder to investigate.
You mentioned you inherited this project. What Gradle version do you use? If it’s an outdated one, I’d suggest to try updating to a more recent version.