Table of contents
  1. Debug
    1. build.gradle
    2. Remote Debugging in Gradle
    3. Running instructions
      1. Step1:
      2. Step2:




Debug

./gradlew runSingle --debug-jvm -PmainClass=Mai

build.gradle

test {
    debugOptions {
        enabled = true
        port = 4455
        server = true
        suspend = true
    }
}

or

run{
debugOptions {
        enabled = true
        port = 4455
        server = true
        suspend = true
    }
 }

Remote Debugging in Gradle

tasks.withType(JavaExec) {
    if (System.getProperty('DEBUG', 'false') == 'true') {
        jvmArgs '-Xdebug', '-Xrunjdwp:transport=debug_socket,server=y,suspend=y,address=9099'
    }
}

To know what’s happening with the arguments, read this about the arguments that you need to send to jvm to make remote debugging possible:
enable-remote-debugging

Running instructions

Step1:

gradle -DDEBUG=true run

Now in the console you will see something like this:

Listening for transport debug_socket at address: 9099

Step2:

Configuration -> Remote Java Application

  • set these fields:
    1. project
    2. host (here its localhost)
    3. port (in this example it will be 9099)