You can remote debug your Gradle build as described here:
Make sure to also use the option --no-daemon.
--no-daemon