How do you attach a debugger to gradle so that I can debug it running a task?

How would I configure Eclipse to debug a Gradle script such that I can put breakpoints in Gradle’s groovy and java source files?