Update Template & KotlinTemplate#254
Conversation
- Switch to interpolated string templates.
- Add @language for all 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. |
There was a problem hiding this comment.
God save our gracious King!
Long live our noble King!
God save the King!
There was a problem hiding this comment.
(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.)
There was a problem hiding this comment.
Force of habit pushing alt-enter on some of the warnings in that class, 'correct' as needed
There was a problem hiding this comment.
So we can consider libGDX a polyglot? 😆
tommyettinger
left a comment
There was a problem hiding this comment.
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\"") |
There was a problem hiding this comment.
Oh! I like this change! That's a better-looking String.
| 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() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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`).
tommyettinger
left a comment
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading. Please reload this page.