To debug a Gradle project in Eclipse, follow these steps:
Step 1 :
Put this in the build.gradle file:
tasks.withType(JavaExec) { if (System.getProperty('DEBUG', 'false') == 'true') { jvmArgs '-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9099' } }
Step 2 :
From the root of your project, run:
gradle -DDEBUG=true run
Now you will see something like this in the console:
Listening for transport dt_socket at address: 9099
Step 3 :
Now set breakpoints in Eclipse in your source files.
Step 4 :
As a last step, now right-click in Eclipse under Project> Debug as> Debug configuration> Remote Java application.
There you must set these fields:
1. Project (this should be set to name of your Eclipse project) 2. Host (here it localhost) 3. Port (in this example it will be 9099)
Click "Debug". Now your program will stop whenever it reaches a breakpoint in Eclipse.
To see the details of these steps with an example project, see the following example on GitHub :
Ayon Nahiyan
source share