7

I am adding the GRADLE_OPTS to system environment variables as:

-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005  

I have created the remote debugger from InteliJ IDEA for this socket. I can debug the build.gradle file, but I can't enter into the scripts for example can't see the variable values .

Cœur
  • 37,241
  • 25
  • 195
  • 267
Gev
  • 125
  • 1
  • 1
  • 5
  • Does this answer your question? [How to debug a Gradle build.gradle file (in a debugger, with breakpoints)?](https://stackoverflow.com/questions/28437636/how-to-debug-a-gradle-build-gradle-file-in-a-debugger-with-breakpoints) – charlie_pl Feb 08 '21 at 13:12

2 Answers2

22

Here are the steps to remotely debug gradle:

Step-by-step guide
1. Run your Gradle command
2. On the command line, execute your task normally, but add the following additional parameters:

-Dorg.gradle.jvmargs='-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=5005,suspend=y'

The "suspend=y" part will pause the execution for you to attach a debugger.

Attach a debugger:

  1. Open the Gradle source code in IntelliJ
  2. Go to Run -> Edit Configurations
  3. Add a new Configuration by clicking the + in the upper left corner
  4. Select Remote, rename it if you choose, and click OK
  5. Set your breakpoints
  6. Go to Run -> Debug "" (defaults to "Unnamed")
Pritam Banerjee
  • 17,953
  • 10
  • 93
  • 108
1

I'm adding this as an alternate answer. For me this works as well ./gradlew <command> --debug-jvm

This does the same thing as above but with fewer arguments.

Raj Kumar
  • 1,547
  • 14
  • 19