Debugging with Gradle: See what happens during gradle builds

Posted on Jan 17, 2022

Sometimes the normal gradlew clean build doesn’t really help in the understanding why a gradle build fails.

In my case this issue once occured when a build on a Jenkins server failed, but not on my local machine (classic).

So there are two things which can be really helpful when debugging failed gradle builds.

Being very verbose

The following command will print you information during the gradle build, which can help you during debugging.

./gradlew -d -S clean build

The flag -d tells gradle to log in debug mode.

-S makes gradle to print the full stacktrace, which is very verbose. So don’t get confused when executing this and getting a wall of text. It helps you tracing the executed tasks, sub steps and what exactly gradle is doing during your build.

Read more