You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Writing this as documentation for how I got this working.
The goal
Click run/debug in IDEA (or press Shift+F9/F10).
Gradle builds the Kotlin project.
Game is automatically started after the build finishes.
Game process can be debugged both from IDEA and Godot editor with no additional user action.
The how
Add the following to build.gradle.kts. This creates a Gradle task which will run the game, telling it to attach to the Godot editor for debugging.
tasks.register<Exec>("runGodotGame") {
// Avoid running the game before rebuilding the project.
mustRunAfter("build")
// This can be an arbitrary path.
setWorkingDir(projectDir.absolutePath)
commandLine(
"/path/to/godot.editor.jvm",
// Attach to Godot editor (requires enabling Debug -> Keep Debug Server Open)."--remote-debug", "tcp://127.0.0.1:6007",
// Start main scene of the project instead of the editor."--path", projectDir.absolutePath,
)
}
Change godot_kotlin_configuration.json to include the following line (the jvm_args property should already exist). This makes the game attach to IDEA for debugging (note the server=n).
In the Godot editor menu, enable option Debug -> Keep Debug Server Open. This makes the Godot editor listen for our game process wanting to start remote debugging.
In IDEA, go to Run -> Edit Configurations, then create a Remote JVM Debug task. You can name it listen. Change debugger mode to Listen to remote JVM, and enable Auto restart. Keep the host as localhost and port as 5005 (as this is what we entered in step 2).
In IDEA, go to Run -> Edit Configurations, then create a Gradle task. You can name it build and run game. Set the Run -> Tasks and arguments text field to :build :runGodotGame.
Finally, in IDEA, run the Remote JVM Debuglisten task in debug mode, and then the Gradlebuild and run game task in any mode. The listen task should continue running after the game is closed, allowing another game process to connect.
At this point the game should've started, and you should be able to debug the game using both IDEA's debugger and Godot's remote debugger.
(Optional) Remove --jvm-debug-port=5005 --wait-for-debugger=false options from editor/run/main_run_args in Godot project settings. This will allow running the game from the Godot editor.
What would make this easier
Having to change the jvm_args in godot_kotlin_configuration.json creates a permanent change to the project configuration. Having an argument like --jvm-debug-port which would make the JVM debug agent connect to a running server instead of starting one would allow putting everything in the Gradle build configuration.
Being able to run the game immediately after a Gradle build triggered in Godot would be neat. This can currently be achieved by making the runGodotGame task always run after build, but that seems undesirable.
I don't know if it's specific to me, but at least on my system stopping the Gradle task in IDEA doesn't close the game. This could be due to the game process detaching from the exec task's shell.
The text was updated successfully, but these errors were encountered:
Writing this as documentation for how I got this working.
The goal
The how
build.gradle.kts
. This creates a Gradle task which will run the game, telling it to attach to the Godot editor for debugging.godot_kotlin_configuration.json
to include the following line (thejvm_args
property should already exist). This makes the game attach to IDEA for debugging (note theserver=n
).In the Godot editor menu, enable option
Debug -> Keep Debug Server Open
. This makes the Godot editor listen for our game process wanting to start remote debugging.In IDEA, go to
Run -> Edit Configurations
, then create aRemote JVM Debug
task. You can name itlisten
. Changedebugger mode
toListen to remote JVM
, and enableAuto restart
. Keep the host aslocalhost
and port as5005
(as this is what we entered in step 2).In IDEA, go to
Run -> Edit Configurations
, then create aGradle
task. You can name itbuild and run game
. Set theRun -> Tasks and arguments
text field to:build :runGodotGame
.Finally, in IDEA, run the
Remote JVM Debug
listen
task in debug mode, and then theGradle
build and run game
task in any mode. Thelisten
task should continue running after the game is closed, allowing another game process to connect.At this point the game should've started, and you should be able to debug the game using both IDEA's debugger and Godot's remote debugger.
(Optional) Remove
--jvm-debug-port=5005 --wait-for-debugger=false
options fromeditor/run/main_run_args
in Godot project settings. This will allow running the game from the Godot editor.What would make this easier
Having to change the
jvm_args
ingodot_kotlin_configuration.json
creates a permanent change to the project configuration. Having an argument like--jvm-debug-port
which would make the JVM debug agent connect to a running server instead of starting one would allow putting everything in the Gradle build configuration.Being able to run the game immediately after a Gradle build triggered in Godot would be neat. This can currently be achieved by making the
runGodotGame
task always run afterbuild
, but that seems undesirable.I don't know if it's specific to me, but at least on my system stopping the Gradle task in IDEA doesn't close the game. This could be due to the game process detaching from the exec task's shell.
The text was updated successfully, but these errors were encountered: