如何从IDEA + Gradle调试AppEngine本地服务器? [英] How to debug the AppEngine local server from IDEA+Gradle?

查看:91
本文介绍了如何从IDEA + Gradle调试AppEngine本地服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循Udacity App Engine课程,但作为修补程序,我使用Gradle和IDEA(开放源代码版本)。



我已经设置了项目成功使用以下build.gradle文件

  buildscript {
储存库{
mavenCentral()


依赖项{
classpath'com.google.appengine:gradle-appengine-plugin:1.9.7'
}
}

apply plugin:'war'
apply plugin:'appengine'

sourceCompatibility = 1.8
version ='1.0'

appengine {
daemon = true
downloadSdk = true

appcfg {
oauth2 = true
}
}

储存库{
mavenCentral()
mavenLocal()
}

依赖项{
appengineSdk'com.google.appengine:appengine-java-sdk:1.9.7 '

compile'c​​om.google.inject:guice:3.0'
compile'c​​om.googlecode .objectify:objectify:5.0.3'
compile'c​​om.google.appengine:appengine-api-1.0-sdk:1.9.7'
compile'c​​om.google.appengine:appengine-endpoints:1.9 .7'
编译'javax.servlet:servlet-api:2.5'
编译'javax.inject:javax.inject:1'

testCompile'junit:junit:4.11 '
testCompile'c​​om.google.appengine:appengine-testing:1.9.7'
testCompile'c​​om.google.appengine:appengine-api-stubs:1.9.7'
}

我使用Gradle运行配置和 appengineRun从IDEA运行本地开发服务器配置并使用 appengineStop 的另一个任务停止它。这是工作,但我没有能力调试,因为我放的断点没有被打。



我相信这个问题与断点是因为IDEA不知道(我是可怕的是在双关语),它必须挂钩到支持AppEngine服务器的码头服务器,但这是一个狂野的镜头,因为我不知道IDEA的内部,更不用说它如何处理Gradle执行。 b

我如何重新获得断点能力?如果没有自定义插件,它是否可行?

首先,您必须在中设置JVM调试参数, build.gradle 文件,以便您可以远程调试本地开发服务器。

  appengine { 
...
jvmFlags = ['-Xdebug','-Xrunjdwp:transport = dt_socket,server = y,suspend = n,address = 8000']
}

然后,您需要在IntelliJ IDEA中创建运行/调试配置(基于上述参数)以用于远程运行或调试过程。远程运行/调试使您能够连接到正在运行的JVM。



您可以找到更多详细信息此处。但基本上进入运行/编辑配置... ,在对话框中点击添加新配置(+)并选择远程。确保配置符合JVM标志(特别是端口)。保存并关闭对话框。



启动您的本地开发服务器并连接调试器(运行/调试)。


I'm following the Udacity App Engine course but as the tinker, I'm following using Gradle and IDEA (Open Source edition).

I have setup the project successfully using the following build.gradle file

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.google.appengine:gradle-appengine-plugin:1.9.7'
    }
}

apply plugin: 'war'
apply plugin: 'appengine'

sourceCompatibility = 1.8
version = '1.0'

appengine {
    daemon = true
    downloadSdk = true

    appcfg {
        oauth2 = true
    }
}

repositories {
    mavenCentral()
    mavenLocal()
}

dependencies {
    appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.7'

    compile 'com.google.inject:guice:3.0'
    compile 'com.googlecode.objectify:objectify:5.0.3'
    compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.7'
    compile 'com.google.appengine:appengine-endpoints:1.9.7'
    compile 'javax.servlet:servlet-api:2.5'
    compile 'javax.inject:javax.inject:1'

    testCompile 'junit:junit:4.11'
    testCompile 'com.google.appengine:appengine-testing:1.9.7'
    testCompile 'com.google.appengine:appengine-api-stubs:1.9.7'
}

I am running the local dev server from IDEA using a Gradle run configuration with the appengineRun configuration and stopping it using another task for appengineStop. This is working, but I have no ability to debug as the breakpoints I put are not hit.

I believe this issue with breakpoints is because IDEA has no idea (I am horrible at puns) that it has to hook into the jetty server that backs the AppEngine server, but this is a wild shot as I have no knowledge of IDEA's internals, much less of how it handles Gradle executions.

How can I regain breakpoint ability? Is it feasible without a custom plugin?

解决方案

First you have to set the JVM debug parameters in your build.gradle file so that you are able to debug the local development server remotely.

appengine {
    ...
    jvmFlags = ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000']
}

Then you need to create a run/debug configuration in IntelliJ IDEA (based on the above parameters) to be used for remote running or debugging processes. Remote running/debugging enables you to connect to a running JVM.

You can find more details here. But basically go to the Run / Edit Configurations..., in the dialog box click on Add New Configuration (+) and select Remote. Make sure that the configuration matches JVM flags (especially port). Save and close the dialog box.

Start your local development server and connect debugger (Run / Debug).

这篇关于如何从IDEA + Gradle调试AppEngine本地服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆