Skip to content

Update Template & KotlinTemplate#254

Merged
tommyettinger merged 9 commits intolibgdx:masterfrom
EpicVon2468:master
Jan 17, 2026
Merged

Update Template & KotlinTemplate#254
tommyettinger merged 9 commits intolibgdx:masterfrom
EpicVon2468:master

Conversation

@EpicVon2468
Copy link
Contributor

@EpicVon2468 EpicVon2468 commented Jan 16, 2026

  • Switch to interpolated string templates for the string blocks.
  • Add @language to all templates

EpicVon2468 and others added 6 commits January 16, 2026 15:57
- Switch to interpolated string templates.
- Add `@JvmStatic` to numerous (companion) object functions to allow easier use from Java.
- Switch to proper use of `.compareTo()` as an operator function.
- Update klint rules (I hate this thing please kill it with fire).
- Attempt to remove braces and simplify some lines (and then get nope'd by klint).
- Use KReflect instead of Java Reflection.
- Use KReflect Property References instead of lambda blocks.
- Optimise amount of `String` -> `Int` conversions in the `*Version` classes.
- Specify types explicitly.
- Remove redundant checks where possible.
- `.inheritIO()` :).

tool.setMainClass(TeaVMLauncher.class.getName());
// For many (or most) applications, using a high optimization won't add much to build time.
// For many (or most) applications, using a high optimisation won't add much to build time.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

God save our gracious King!
Long live our noble King!
God save the King!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Optimisation is UK English, like colour or internationalisation. Most programming has settled on US English spelling, which is why you have AWT Color and not AWT Colour. Ideally, we'd stick to US English here, like libGDX itself.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Force of habit pushing alt-enter on some of the warnings in that class, 'correct' as needed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libGDX is a mixture of Englishes. I certainly wouldn't call Pixmap.NearestNeighbour US. It can't make its mind up on canceled versus cancelled. Wouldn't change it for the sake of it, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we can consider libGDX a polyglot? 😆

Copy link
Member

@tommyettinger tommyettinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new use of $$"" Strings is a nice thing, as are the language annotations all over. I'm approving but I'll leave some time in case you want to change anything else, since I need to sleep.


override fun initiate(project: Project) {
project.rootGradle.buildDependencies.add("\"org.jetbrains.kotlin:kotlin-gradle-plugin:\$kotlinVersion\"")
project.rootGradle.buildDependencies.add($$"\"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion\"")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! I like this change! That's a better-looking String.

Comment on lines +35 to +47
private val gradleFiles: MutableMap<String, GradleFile> = mutableMapOf()
val files: MutableList<ProjectFile> = mutableListOf()
val rootGradle: RootGradleFile = RootGradleFile(this)
val properties: MutableMap<String, String> = mutableMapOf()
val gwtInherits: MutableSet<String> = mutableSetOf()
val androidPermissions: MutableSet<String> = mutableSetOf()

val reflectedClasses = mutableSetOf<String>()
val reflectedPackages = mutableSetOf<String>()
val reflectedClasses: MutableSet<String> = mutableSetOf()
val reflectedPackages: MutableSet<String> = mutableSetOf()

// README.md:
var readmeDescription = ""
private val gradleTaskDescriptions = mutableMapOf<String, String>()
var readmeDescription: String = ""
private val gradleTaskDescriptions: MutableMap<String, String> = mutableMapOf()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks good, and I think the explicit types are good too. Using init before was something I wasn't really sure about in Kotlin.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I saw, the only reason the init block was present was due to a misunderstanding of Map<T> vs MutableMap<T>

- Convert all `Language` subclasses (`class` -> `data object`).
- Allow basic Kotlin syntax to actually be used (disable five (more) klint rules).
- Update code that used `ArrayList<T>` to use `(Mutable)List<T>`.
- Formatting.
- Convert some if statements to when statements.
- Specify types explicitly.
- Update reflection instantiation of `Language` subclasses to be compatible with `class` or `object`.
- Remove redundant suppressions.
- Switch to string templates where possible.
- Convert `KtxRepository` (`object` -> `data object`).
- Delegate `Preset#languagesData` to lazy.
Copy link
Member

@tommyettinger tommyettinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read as much of this as I could focus on; there's a lot here. Much more than Template code changed at this point, but the changes are all appreciated. Everything looks cleaner, so... I guess I'll merge and test all the things I need to test locally.

@tommyettinger tommyettinger merged commit f3e96e4 into libgdx:master Jan 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants