How to run Jetty via Gradle in Debug Mode

后端 未结 9 1482
醉话见心
醉话见心 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 01:10

    Are you running gradle in daemon mode? As I understand it the daemon will then be running the jetty instance. Therefore you'll need to set the JVM args for the daemon. This should be possible by setting the org.gradle.jvmargs in gradle.properties.

    See http://gradle.org/docs/current/userguide/tutorial_this_and_that.html#sec:gradle_properties_and_system_properties

    Simply project that works here in non-daemon mode

    build.gradle:

    apply plugin: 'idea'
    apply plugin: 'jetty'
    

    src/main/java/com/Test.java:

    package com;
    public class Test {
        static public String greet() {
            return "Hi";
        }
    }
    

    src/main/webapp/index.jsp:

    <%@ page import="com.Test" %>
    
    <%= Test.greet() %>
    
    

    Command-line (in cygwin though):

    $ GRADLE_OPTS='-Xdebug -Xrunjdwp:transport=dt_socket,address=9999,server=y,suspend=n' gradle jettyRun
    

    Gradle then hangs and I can put debugger from Intellij on port 9999 and set a breakpoint in the java file. When I then try to open the web page jetty informs me about I will hit the breakpoint.

提交回复
热议问题