Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I use javafx-gradle-plugin and want to debug the program with IDEA, but failed #77

Open
Gohan opened this issue Jul 19, 2017 · 5 comments

Comments

@Gohan
Copy link

Gohan commented Jul 19, 2017

Is there any debuggable example working for IDEA + gradle ?

Tried the gradle Debug "jfxRun" using IDEA, but not working..

netstat -an | find "5005"
not find the debug server port..

my build.gradle looks like below:

group 'com.baozs.atwork.tools'
version '1.0-SNAPSHOT'

buildscript {
    ext.kotlin_version = '1.1.3'

    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath group: 'de.dynamicfiles.projects.gradle.plugins', name: 'javafx-gradle-plugin', version: '8.8.2'
    }
}

apply plugin: 'java'
apply plugin: 'kotlin'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

compileKotlin {
    kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
}


jar {
    manifest {
        attributes(
                'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
                'Main-Class': 'com.baozs.atwork.tools.QIMSyncTools.app.MainKt'
        )
    }
}

apply plugin: 'javafx-gradle-plugin'
jfx {
    // minimal requirement for jfxJar-task
    // com.baozs.atwork.tools.QIMSyncTools.app.MainKt
    verbose = true
    mainClass = 'com.baozs.atwork.tools.QIMSyncTools.app.MainKt'
    manifestAttributes = new HashMap<String, String>()
    manifestAttributes['Main-Class'] = 'com.baozs.atwork.tools.QIMSyncTools.app.MainKt'

    // minimal requirement for jfxNative-task
    vendor = 'SyncToolsGui'

    jvmArgs = ["-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"]
    launcherArguments = ["-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"]
}

task fatJfxJar(type: Jar) {
    baseName = project.name + '-fat'
    manifest {
        attributes["Main-Class"] = "com.baozs.atwork.tools.QIMSyncTools.app.MainKt"
    }
    from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } }
    with jar
}
@Gohan
Copy link
Author

Gohan commented Jul 19, 2017

also tried the demo, not working either:
image

@FibreFoX
Copy link
Owner

Hi, you might want to use runJavaParameter for this

jfx {
    runJavaParameter = '-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005'
}

This parameter was introduced to have debug-settings running, but not having this in production outcome.

@Gohan
Copy link
Author

Gohan commented Jul 20, 2017

I'll try it tonight !
It works!

@Gohan Gohan closed this as completed Jul 20, 2017
@zvpdev
Copy link

zvpdev commented Aug 16, 2017

Can't repeat this in my.

build.gradle

group 'ru.mc'
version '1.0'

buildscript {
    dependencies {
        classpath group: 'de.dynamicfiles.projects.gradle.plugins', name: 'javafx-gradle-plugin', version: '8.8.2'
    }

    repositories {
        mavenLocal()
        mavenCentral()
    }
}

apply plugin: 'java'
sourceCompatibility = 1.8

repositories {
    mavenLocal()
    mavenCentral()
}

apply plugin: 'javafx-gradle-plugin'

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

jfx {
    verbose = true
    mainClass = 'ru.mc.ltec.MainClass'
    vendor = 'dev'
    runJavaParameter = '-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005'
}

Set breakpoint (for example to MainClass.launch(args) method) and click Debug for jfxRun task.

Running log

12:09:54: Executing external task 'jfxRun'...
:compileJava UP-TO-DATE
:processResources NO-SOURCE
:classes UP-TO-DATE
:jar UP-TO-DATE
:jfxJar
:jfxRun
Running JavaFX Application
Running command: java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar project-jfx.jar

Application starts immediately without stopping.

I need some additional actions about which in the topic was not explicitly mentioned above?

@lightsuner
Copy link
Contributor

lightsuner commented Dec 6, 2017

Hi @zvpdev, did you solve this issue?

Hi @FibreFoX when I run debug mode with
runJavaParameter = '-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005'
it's not work (port 5005 isn't open).

But when I run command:
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar project-jfx.jar manually - it opens the port 5005.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants