Application not debuggable (IntelliJ)

Hello fellow Gradlers,

I’ve got a pretty straight-forward build.gradle for a JavaFX-application:

apply plugin: 'java'
apply plugin: 'application'

sourceCompatibility = 1.8

mainClassName = 'SomeMainClass'

project.ext {
   assetsDir = rootProject.project(':android').file('assets')
}

dependencies {
   // Some dependencies
}

task runDebug(type: JavaExec) {
debug true
}

configure([run, runDebug]) {
classpath = sourceSets.main.runtimeClasspath

main = mainClassName
args "assetsDir=\"$assetsDir\""
}

When I try to execute :run from IntelliJ, the application starts as it would normally, but I can’t debug it out of the box. With :runDebug, I am able to attach a remote debugger and I am in fact able to debug the entry-point, but JavaFX starts the actual application in another thread which neither is debuggable, nor the console output from this thread gets displayed. Other than that, the application works just fine (well actually, it doesn’t, that’s why I need to debug).

I already made sure Gradle and the application run the same Java version (while IntelliJ uses its own distribution of Java which I don’t think is a problem).

Another weird thing is, when I execute gradle tasks from the IDE, I get the Configuration on demand is an incubating feature-Warning. It doesn’t appear if I execute tasks via command line and I don’t have a gradle.properties in the project in which configuration on demand could have been enabled, and my gradle.properties in my home/.gradle-folder only enables the daemon.

I have this problem for a few weeks now and it is really frustrating, since I am kinda stuck now with it. Of course, it worked before and it kept working for a long time. I didn’t make any significant changes to the gradle-files in that time, so it probably is a configuration-thing, but it also occurs on two different systems.

Any help is greatly appreciated. Thanks!

It’s hard to tell whats going wrong here. How do you invoke the gradle task? from commandline or via the idea api. Could you share a reproducable example of this problem?

cheers,
René

I (would like to) invoke the task via Idea. Actually, i just tried around some more and noticed that I can debug everything, including JavaFX’s thread, by starting the runDebug-task via console and attaching IntelliJ’s remote debugger. This could be a solution, but this whole thing is still weird.

As i said, i’m fairly sure it is something IDE-related. IntelliJ also configures an Android-gradle facet for each sub-project, although only one sub-project is actually using Android (and nothing depends on it).

This is my root build.gradle:

apply plugin: 'idea'

allprojects {
    version = '1.0'

    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }

    tasks.withType(JavaCompile) {
        options.encoding = 'UTF-8'
    }
}

Other than this one and the previously posted subproject’s build.gradle, i don’t think any other files are of relevance.

For now, I will just go with invoking my :runDebug-task via terminal and attaching a remote-debugger to it. If i find out something else, i will post another reply.

Out of curiousity, why can’t you invoke the Main class directly in IDEA?

Actually, I was so focused on getting it to work with Gradle, that i haven’t even thought about it.