Closed ThomasDaheim closed 6 years ago
As I understand, you have created a new task with different name. Are you using the "Debugger listens for connection" mode to debug? If you are, then have you updated the -PdebuggedTaskName=${project}:run
in the built-in tasks? In this case, you don't actually need separate run and debug tasks as the init script NB provides will update the jvmArgs property (in an afterEvaluate block).
Based on the tip from stackoverflow I have added a configuration like
run {
doFirst {
jvmArgs = [
'--module-path', classpath.asPath,
'--add-modules', 'javafx.controls,javafx.graphics,javafx.base,javafx.fxml,javafx.web,javafx.swing,javafx.media',
// various exports needed at run time - see https://stackoverflow.com/a/52142071
'--add-exports', 'javafx.graphics/com.sun.javafx.util=ALL-UNNAMED',
'--add-exports', 'javafx.base/com.sun.javafx.reflect=ALL-UNNAMED',
'--add-exports', 'javafx.base/com.sun.javafx.beans=ALL-UNNAMED',
'--add-exports', 'javafx.base/com.sun.javafx.logging=ALL-UNNAMED',
'--add-exports', 'javafx.base/com.sun.javafx.runtime=ALL-UNNAMED',
'--add-exports', 'javafx.base/com.sun.javafx.collections=ALL-UNNAMED',
'--add-exports', 'javafx.graphics/com.sun.prism=ALL-UNNAMED',
'--add-exports', 'javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED',
'--add-exports', 'javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED',
'--add-exports', 'javafx.media/com.sun.media.jfxmedia=ALL-UNNAMED',
'--add-exports', 'javafx.media/com.sun.media.jfxmedia.events=ALL-UNNAMED',
'--add-exports', 'javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED',
'--add-exports', 'javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED',
'--add-exports', 'javafx.controls/com.sun.javafx.scene.control.inputmap=ALL-UNNAMED',
'--add-exports', 'javafx.graphics/com.sun.javafx.scene.traversal=ALL-UNNAMED',
]
}
}
in my build.gradle. With this the standard "Run" tasks works. But it doesn't impact the "Debug" task - that still fails with "JavaFX libs not found". So I was playing around to also get Debug running but with no luck.
What would I need to do to have the same impact on the "Debug" task? If possible I would like to avoid having to create a new task and having to attach the debugger manually...
Can you try switching to the other debug mode? In project properties (or even in the global settings): Set Debugging-Java/Debug mode to "Debugger listens for connection". Then, you should probably reset the debug tasks (assuming you have configured it in project properties) to the default (inherit).
Oh, right that won't work because you are setting the jvmArgs in a doFirst. If you want to do this in doFirst (or anywhere after project evaluation), then write something like
def newArgs = [/* Your args go here */]
jvmArgs = jvmArgs.plus(newArgs)
Cool, jvmArgs.plus seems to do the job!
My build.gradle now looks like below. I couldn't include classpath.asPath in the definition of newArgs since it doesn't seem to be available outside of doFirst?
def newArgs = [ '--add-modules', 'javafx.controls,javafx.graphics,javafx.base,javafx.fxml,javafx.web,javafx.swing,javafx.media',
// various exports needed at run time - see https://stackoverflow.com/a/52142071
'--add-exports', 'javafx.graphics/com.sun.javafx.util=ALL-UNNAMED',
'--add-exports', 'javafx.base/com.sun.javafx.reflect=ALL-UNNAMED',
'--add-exports', 'javafx.base/com.sun.javafx.beans=ALL-UNNAMED',
'--add-exports', 'javafx.base/com.sun.javafx.logging=ALL-UNNAMED',
'--add-exports', 'javafx.base/com.sun.javafx.runtime=ALL-UNNAMED',
'--add-exports', 'javafx.base/com.sun.javafx.collections=ALL-UNNAMED',
'--add-exports', 'javafx.graphics/com.sun.prism=ALL-UNNAMED',
'--add-exports', 'javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED',
'--add-exports', 'javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED',
'--add-exports', 'javafx.media/com.sun.media.jfxmedia=ALL-UNNAMED',
'--add-exports', 'javafx.media/com.sun.media.jfxmedia.events=ALL-UNNAMED',
'--add-exports', 'javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED',
'--add-exports', 'javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED',
'--add-exports', 'javafx.controls/com.sun.javafx.scene.control.inputmap=ALL-UNNAMED',
'--add-exports', 'javafx.graphics/com.sun.javafx.scene.traversal=ALL-UNNAMED',
]
// extend Netbeans Gradle "Run" task
run {
doFirst {
jvmArgs = jvmArgs.plus(['--module-path', classpath.asPath,])
jvmArgs = jvmArgs.plus(newArgs)
}
}
// extend Netbeans Gradle "Debug" task
task(debug, dependsOn: 'classes', type: JavaExec) {
doFirst {
main = 'tf.gpx.edit.main.GPXEditorManager'
classpath = sourceSets.main.runtimeClasspath
jvmArgs = jvmArgs.plus([
'--module-path', classpath.asPath,
"-Xdebug",
"-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005",
])
jvmArgs = jvmArgs.plus(newArgs)
}
}
Hi,
in order to have JavaFX11 running under Netbeans 9 and Gradle some tweaks are required (see https://stackoverflow.com/questions/52140346/java11-javafx-and-maven-will-not-run-outside-of-netbeans-ide-9/52142071#52142071). Especially, the standard "Debug" tasks isn't working since it also needs --add-exports and so on.
Using the tip from https://github.com/openjfx/samples/issues/2 I have managed to add a new runDebug task that is working. I can add the same for the "Debug" task but then I seem to overwrite that task since I now must manually start the debugger.
How would I need to add information like
to the Debug task? I have tried to add above jvm commands lines via Properties -> Built-In Tasks but I failed to translate '--module-path', classpath.asPath into something valid...