How to run Jetty via Gradle in Debug Mode

后端 未结 9 1462
醉话见心
醉话见心 2020-12-13 00:43

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

9条回答
  •  独厮守ぢ
    2020-12-13 00:54

    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!

提交回复
热议问题