Does anyone know how to configure the jetty gradle plugin to run in debug mode so that I can attach a remote debugger?
I\'ve tried setting the gradle and java opts t
Im my cases, it doesn't work until I run the following command.
GRADLE_OPTS='-XX:MaxPermSize=256M -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=4001' gradle jettyRun
And when it works, in the server console I can use System.out.println(...)
to inspect what I want to see. As for breakpoint debug, unfortunately, I haven't find a way to it. Anyone knows how, welcome to add complement.
Try using Gretty plugin, it provided gradle tasks jettyRunDebug, jettyStartDebug etc.
Source code and doc: https://github.com/akhikhl/gretty
Disclosure: I am author of Gretty plugin.
set GRADLE_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=9999,server=y,suspend=n
does NOT work for me too when run with gradle jettyRunWar
.
I found another solution which works, run gradle jettyRunWar with below options
gradle -Dorg.gradle.jvmargs="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n" jettyRunWar
.
But when I add the same parameter in gradle.properties, it doesn't work...
Mine's a multi-project gradle build and I tried:
$ export GRADLE_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=9999,suspend=y,server=y"
$ gradle jettyRun
And that did NOT work. I even tried adding -Xnoagent to the GRADLE_OPTS setting above but that too did not make a difference. Also, setting JAVA_OPTS instead of GRADLE_OPTS did not solve the problem either. What solved the problem for me was adding a gradle.properties with:
org.gradle.jvmargs=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=5005,suspend=y
And immediately I could hit the breakpoint. May be solutions mentioned in other answers did not work for me because it is a multi-project build. Not sure!
Just wanted to provide the solution that worked for me in case above solutions do not work for other folks.
P.S: Tried with gradle 1.5/1.6 and adding the setting above to gradle.properties works for both versions!
add this into the build.gradle
jettyRun {
jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005'
}
Also, please look at this two links from official wiki:
https://github.com/akhikhl/gretty/issues/36
http://akhikhl.github.io/gretty-doc/Debugger-support.html
It can help you to properly configurate gretty plugin to debug jetty application with IntelliJ Idea