godot-kotlin-jvm
godot-kotlin-jvm copied to clipboard
Allow separating Godot project from Kotlin project
Currently, it is required to store the Godot and Kotlin projects in the same root directory. This approach leads to mixing configurations and directories of two different project types. While it is somewhat maintainable, it'd be convenient to be able to store both in entirely different folders. Consider the following:
dodge-the-creeps/
├── godot/
│ ├── project.godot
│ ├── main.tscn
│ └── ...
└── kotlin/
├── build.gradle.kts
├── src
└── ...
The clear separation allows to work with only related project files in IntelliJ and/or the Godot editor.
When running a Godot project with the Kotlin counterpart stored in a separate directory, the editor errors with a missing bootstrap file error:
You can define Kotlin modules outside the Godot project, but there is still a mandatory part of it that must be in Godot so the editor can interact with the build.gradle file, .kt files and the jvm directory that contains the jars.
Scripts are regular resources for Godot, and to be useable they have to be reachable from a res:// path, meaning they have to be inside the godot project.
Technically, you can still keep most code outside the Godot project by making a separate module and add it as a dependency in the godot gradle configuration. All your scripts should then have matching .gdj files generated in the Godot project to attach them to nodes.
We actually do that in our tests here:
https://github.com/utopia-rise/godot-kotlin-jvm/tree/master/harness
The main Godot project is the test directory, but it also uses Kotlin code located in flattened-library-tests, fqname-library-tests, hierarchical-library-tests
I imagined part of the build process could be copying .gdj files to then reference them from the editor.
Could you help me understand why running the Godot project from a different directory wouldn't be a matter of providing correct relative paths to jars and other necessary files from the Kotlin project?