korlibs / korge

KorGE Game Engine. Multiplatform Kotlin Game Engine
https://korge.org/
Other
2.5k stars 123 forks source link

Project wizard creates projects with an invalid Android module names #1839

Open GambitDev opened 1 year ago

GambitDev commented 1 year ago

I have called my project "Space Shooter" and I now can't build it for android as this generate a module called "Space Shooter.deps" which is not a valid android name for a module

To fix this I had to add this line to my settings.gradle.kts file: rootProject.name = "SpaceShooter"

That means that the new project created via the Korge plugin in Intellij does not perform any type of check to the project name, I think it would be better for the new project to have a "safe" name based on the project name set by the user, removing spaces and invalid characters and stuff like that and automatically add the "safe" name to the gradle settings file

Kietyo commented 1 year ago

Took a look as to how that wizard works and it looks like it retrieves the starter projects from this file here:

https://store.korge.org/starterkits.json

It then just downloads and unzip the project files for the respective project, with the name of the root directory as whatever name the user sets.

Related file: https://github.com/korlibs/korge-intellij-plugin/blob/main/src/main/kotlin/com/soywiz/korge/intellij/module/wizard/NewKorgeModuleWizardStep.kt

Maybe what we could do is check if there exists a settings.gradle.kts file and append:

rootProject.name = "<safe project name>"
GambitDev commented 1 year ago

can there even be a situation where a Korge project does not have a settings file? I'm pretty new to this repo but was under the impression that Korge uses gradle as a build system

soywiz commented 10 months ago

Yes, generating/updating a settings.gradle.kts with a safe root name could help. Let's speciffy a valid name in templates for now.