Setting a system property of taskName.debug will run the tests in debug mode, suspended and listening on port 5005. For example: gradle test -Dtest.single=ThisUniquelyNamedTest -Dtest.debug
but that doesn’t seem to work for arbitrary tasks. e.g. gradle tasks -Dtasks.debug
Just debug it like you would debug any external Java application. Depending on which debug settings you want, put something like the following into GRADLE_OPTS:
I, too, want to debug into Gradle code to better understand test report generation. I was having problems getting GRADLE_OPTS to propagate to spawned JVMs (I must have been doing something wrong). By that I mean that the JVM that handles the command line invocation of Gradle is not the same one that handles running your tests, and I could not get my debugger client (IntelliJ) to stop at a breakpoint in Gradle code in the test-running VM.
Here is how I solved it. Add the JVM debugging config to $HOME/.gradle/gradle.properties like this:
See my post above. Setting breakpoints in build scripts isn’t currently supported, but you should be able to set breakpoints in plugin or task classes.
Some more information on this would definitely be helpful. I’ve mad mixed results with eclipse & gradle so far.
I have been able to debug java/groovy that’s being called from gradle when running on anther system and using eclipse’s remote java app debug config combined with the GRADLE_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"
Note that this needs to be set in the env, it’s not picked up from ~/.gradle/gradle.properties as documented. Maybe I’m doing something wrong, but this is ignored: org.gradle.jvmargs="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"
I’ve had mixed results being able to stop on breakpoints when running as a remote java app. It’s probably related to where eclipse is looking for src/class files and maybe I don’t have that setup exactly right.
What I’d like to do is run gradle directly from eclipse directly and be able to hit breakpoints in my buildSrc/**/src/main/java classes.
I did the eclipse import gradle project for my project, and it recognizes it as a gradle project, but I don’t see how to run/debug it from eclipse.
‘GRADLE_OPTS’ is only used by the Gradle (client) JVM. Your code should attach a debugger to the daemon JVM, not the test JVM.
The easiest way to debug a Gradle build is ‘gradle someTask --no-daemon -Dorg.gradle.debug=true’. Tests can be debugged with ‘gradle test -Dtest.debug=true’.