Win 10, Git Bash, gradlew, multiple debug-jvm, specify different ports

I would just add the following to your build.gradle:

bootRun {
    debugOptions {
        port = Integer.valueOf(findProperty('debugPort') ?: port.get())
        suspend = false // optional
    }
}

You can then run on the default port with no extra argument:

./gradlew -b ./folder-a/service-a/build.gradle bootRun --debug-jvm

or on another port with -PdebugPort={port}:

./gradlew -b ./folder-a/service-b/build.gradle bootRun --debug-jvm -PdebugPort=6543

This is what should happen until you attach the debugger on the specified port because in the command line args, suspend=y. I included an optional suspend = false line that you can include if you want the application to start up ready to debug, but not wait for you to attach the debugger.

1 Like