如何调试使用Gradle构建的Play 2应用程序 [英] How to debug Play 2 Application built with Gradle

查看:215
本文介绍了如何调试使用Gradle构建的Play 2应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎有广泛的文档





我遇到的问题是:断点永远不会被打击,处理继续正常。 技术:播放2.3.X,IDEA 14.1,Gradle 2.8,Scala 2.10



我一定缺少一些东西,是什么?

解决方案

您将debug参数设置在错误的位置。在GRADLE_OPTS中设置它定义了当您运行Gradle时要使用的系统属性。因此,考虑到Gradle启动一个新的JVM进程来执行Play Framework应用程序,您必须将这些属性传递给运行该应用程序的JVM。



您可以使用PlayRun任务添加JVM参数。这样的东西:

  tasks.withType(PlayRun){
forkOptions.jvmArgs = ['-Xdebug',
'-Xrunjdwp:transport = dt_socket,server = y,suspend = n,address = 9999]
}

但请注意,此设置将在每次执行应用程序时设置调试模式。也许你应该添加一些参数来验证,如果你想要调试模式。



之后,您通常可以在IDE中设置远程调试。



希望它有帮助; / p>

There seems to be extensive documentation for debugging Play applications with IntelliJ IDEA, but they all assume that Play is built with SBT.

Debugging with Gradle should be as easy as:

  • Set some breakpoints
  • Run GRADLE_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9999" gradlew --no-daemon :runPlayBinary
  • Run an IntelliJ Remote Configuration that looks like this:

The problem I'm having is: the breakpoint is never hit, processing continues as normal. Technologies: Play 2.3.X, IDEA 14.1, Gradle 2.8, Scala 2.10

I must be missing something, what is it?

解决方案

You're setting the debug argument in the wrong place. Setting it in the GRADLE_OPTS defines a system property to use when you're running Gradle. So, given the fact that Gradle starts a new JVM process to execute the Play Framework application, you must carry these properties to the JVM runnning the application.

You can use the PlayRun task to add the JVM arguments. Something like this:

tasks.withType(PlayRun) {
    forkOptions.jvmArgs = ['-Xdebug', 
                          '-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9999]
}

But notice that this setting will set the debug mode every time you execute the application. Maybe you should add some argument to validate if you want the debug mode.

After that, you can normally set the remote debug in your IDE.

Hope it helps ;)

这篇关于如何调试使用Gradle构建的Play 2应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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