-
Notifications
You must be signed in to change notification settings - Fork 53
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
Change the Gradle DSL of generated projects from Groovy to Kotlin #220
Comments
I was just about to write the same thing. It may be worth gradually changing it first in templates and then in projects (gdx-liftoff, libgdx and so on). |
This would be a great idea if libGDX was a brand-new, green-field project that had just put out its 0.1.0 release. This is not the state of things. Changing the buildscript language would require changing all documentation involving Gradle, whether it is in libGDX proper or not. This is documentation in various places that can sometimes be 5 years old and still accurate today, though going back to when dependencies used I know the Kotlin Gradle DSL offers new and good features, like code completion that isn't completely brain-dead (and Groovy really isn't meant for that). The thing is, ideally new users should only need to barely touch Gradle scripts at all, and copy-paste from existing docs should really be sufficient for users who aren't trying to run complex code at build-time. Completing this issue would make us lose that feature until either:
All of those seem like significant undertakings, or just impossible. I would of course love to be able to always use the newest and shiniest technology, with no downsides! I would also personally prefer to use leiningen as my build system, instead of Gradle, since it is so much drastically simpler to write a build script! Neither of these are happening, though. Sometimes keeping things stable is a much better plan than improving things by breaking all of them and making users pick up the pieces. |
Okay, I understand you. I could create such a template, and we could add it, but as I mentioned before, I'm just learning libGDX and couldn't immediately find where the templates for liftoff are stored. upd: I mean the new default template that contains Kotlin and Kotlin DSL in gradle scripts both |
Liftoff pieces together Gradle scripts mostly in code, the Kotlin part of src. When users select platforms, that adds Gradle files for LWJGL3, Android, iOS via RoboVM, etc. in their own projects. When the Java version changes, that sometimes can work just by changing that variable, but sometimes needs deeper changes in some of those platform projects. When dependencies are added, usually that affects It might make more sense to have simple, small, pre-made projects using the kts scripts, that users could customize for their own game. This is the approach I do for my library template, which isn't related to Liftoff. This is also the approach I recommend when people can't run Liftoff due to having a headless machine; there's an option somewhere that makes Liftoff generate sample projects, and I usually run it via a Gradle task. I know @Quillraven has some good .kts-based projects, and Spitfire looks like an impressive amount of work (7 years! Wow!). Maybe copying and stripping one of those projects down to a bare minimum, getting it to support TeaVM, Android, and other common Kotlin platforms, and making that a base project for people to edit would be the easiest route. |
I don't have that many projects anymore with Kotlin Gradle because most of my projects are created out of liftoff and I personally don't care anymore in which language those build scripts are written. The important part is that they run ;) Anyway here is one example project with with android and desktop but it is ~5 years old. Still, could be useful as a starting point for a template. Here is one more example but also 5 years old. Here is a more up to date kotlin multiplatform example of Fleks ECS. Besides that, there are so many ways in Gradle to solve a specific problem (which I personally don't like a lot) so someone needs to decide how a template should look like. Do we want Again, I personally don't really care and just use whatever liftoff throws at me. Those files are almost never touched besides maybe adding a dependency and I don't care if the string is with single or double quotes or if it uses a catalogue version or not. But that's just my personal opinion on that topic :) |
Thanks a lot for your input to this discussion, especially @tommyettinger. It's unfortunate but it's the reality. That said I still think there are some very low hanging fruits we can do – use simple Groovy in gdx-liftoff's templates (i.e don't use wild features). Practical examples:
The above things are quite easy to contribute, and they will benefit:
|
Note
Moved from libgdx/libgdx#7056
Synopsis
gdx-liftoff
generates libGDX projects that use Groovy DSL for its Gradle buildscripts. It'd be better to use Kotlin instead of Groovy.Details
Since April 2024 (almost 2 years ago), Gradle recommends using Kotlin instead of Groovy for buildscripts.
Citing Gradle docs:
I can only agree with the above – in my experience, using Kotlin DSL for Gradle makes it more pleasant and involves much less guesswork.
I think that letting users choose between Groovy DSL or Kotlin DSL can be a non-goal of this issue: Groovy is being slowly but steadily being phased out by Gradle. Offering just Kotlin DSL would be enough.
Useful resources
The text was updated successfully, but these errors were encountered: