3

我正在尝试在 IntelliJ 中调试一个简单的 gradle Java 应用程序,但我遇到了最困难的时间。我可以从 JetGradle 插件运行我的任务就好了,但是当我右键单击任务并尝试调试它时,我在控制台中收到一条消息,说它已连接,然后它说等效的断开连接:

Disconnected from the target VM, address: '127.0.0.1:59303', transport: 'socket'

不太确定如何从这里开始。我试过在网上找等,除了人们谈论 JetGradle 插件不是很好外,并没有真正找到太多。

如果重要的话,这是我的 build.gradle。

apply plugin: 'java'
apply plugin: 'idea'

task(parse, dependsOn: 'classes', type: JavaExec) {
    main = 'com.test.creator.Main'
    classpath = sourceSets.main.runtimeClasspath
}

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'org.xerial:sqlite-jdbc:3.7.2'
    compile 'net.sourceforge.jexcelapi:jxl:2.6.12'
}

任何帮助或方向将不胜感激。

需要注意的一些额外事项:

  • 我正在使用 gradle Daemon,因为它极大地减少了我在某些项目中的构建时间,所以我更愿意继续使用它。
  • 我正在使用 Gradle Wrapper。
  • 我正在运行 IntelliJ 12.1.6
4

1 回答 1

1

I'm not sure if right-clicking the Gradle task and hitting Debug is the right solution (you might be debugging Gradle here, rather than your application). The easiest solution is to just run/debug the com.test.creator.Main class directly (from IntelliJ).

PS: Gradle support is much better in IntelliJ 13 (EAP).

于 2013-11-17T05:19:10.797 回答