使用Intellij在gradle项目中设置断点 [英] Using Intellij to set breakpoints in gradle project

查看:723
本文介绍了使用Intellij在gradle项目中设置断点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在IntelliJ 12.1出来了,我希望能够将调试器附加到'gradle run'应用程序并让它停在断点处。我已经尝试了右键单击运行并选择调试它,并按照此答案中的建议设置GRADLE_OPTS环境变量:

使用IntelliJ调试Gradle插件



远程连接调试器,它工作正常,但没有一个在断点上突破。

解决方案

我可以通过配置 run 任务。由于它是 JavaExec 任务,它支持jvmArgs属性:

  run {
jvmArgs-agentlib:jdwp = transport = dt_socket,server = y, suspend = y,address = 5005

和调试属性:

 运行{
debug true
}

右击调试似乎不起作用,因为IntelliJ将调试器连接到错误的JVM,即gradle。


Now that IntelliJ 12.1 is out, I was hoping to be able to attach the debugger to a 'gradle run' app and have it stop at breakpoints. I've tried both right-clicking run and choosing to debug it, and setting GRADLE_OPTS environment variables as suggested in this answer:

Debug Gradle plugins with IntelliJ

and attaching the debugger remotely, which works fine, but neither one breaks on the breakpoints. I must be missing something.

解决方案

I can debug remotely by configuring the run task. Since it is a JavaExec task, it supports jvmArgs properties:

run {
    jvmArgs "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"
}

and debug properties:

run {
    debug true
}

Right clicking to debug doesn't seem to work because IntelliJ is attaching the debugger to the wrong JVM i.e. gradle.

这篇关于使用Intellij在gradle项目中设置断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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