Search code examples
debuggingintellij-ideagradlegradlew

Debugging simple Gradle Java App in Intellij


I'm trying to debug a simple gradle Java app in IntelliJ and I'm having the hardest time. I can run my tasks from the JetGradle plugin just fine, but when I right click the task and try to debug it, I get a message in the console that says it's connected, and then it says the equivalent disconnected:

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

Not really sure how to proceed from here. I've tried looking online etc and haven't really found much except people talking about how JetGradle plugin isn't very good.

Here is my build.gradle if it matters.

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'
}

Any help or direction would be appreciated.

A few additional things to note:

  • I'm using the gradle Daemon as it dramatically decreased my build time with certain projects, so I'd prefer to keep that on.
  • I'm using the Gradle Wrapper.
  • I'm running IntelliJ 12.1.6

Solution

  • 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).