How to restart failed build automatically?


I’d like to restart build that fails on dependency resolution (project evaluation). Luckily, Gradle allows to handle different stages of build lifecycle via various listeners/notifications. So I’m wondering if it possible to restart build when an error happens by means of Gradle itself? Or should I use external shell script/something similar?


Dependency resolution happens on-the-fly, which usually means execution rather than configuration time. What’s the idea behind restarting the build? Are you trying to implement some kind of retry behavior?

Yep, retry of build in “single” run is what I want to achieve if possible. Currently, after build fails I have to do some tinkering in Gradle’s cache to make build run (update several POMs) and after that build runs OK. Restarting the build without any changes makes no sense to me and I have to admit that this is rather exceptional behavior. But it allows to avoid two things if done by Gradle itself: 1) failing the build for the first time and 2) restarting it. Sounds like this can’t be done in the way I want it to be. Thanks for clarification!