chore: Upgrade project to Gradle and AGP 9 and korlibs 7.0.0-SNAPSHOT#2364
chore: Upgrade project to Gradle and AGP 9 and korlibs 7.0.0-SNAPSHOT#2364malliaridis wants to merge 22 commits into
Conversation
|
I removed ABI validation from this PR to enable it in a separate PR. ABI validation was not enabled before, and it adds a couple thousand lines of code, which hid the actual impact of this PR. |
|
Tests are failing with: We could publish |
Yes, a snapshot release would allow us to run the build for this one. We probably have to add the snapshots repository to the dependency management repositories, but that should be simple enough. |
| '--enable-unsafe-webgpu', // Enable WebGPU | ||
| '--enable-features=Vulkan', // Enable Vulkan | ||
| '--no-sandbox', // Optional: Helps to run Chrome in certain CI environments | ||
| '--disable-dev-shm-usage', // Optional: Helps to avoid issues with /dev/shm partition in certain CI environments | ||
| '--headless', // Ensures that Chrome runs in headless mode | ||
| //'--disable-gpu', // Optional: Disable hardware GPU acceleration (useful in some CI environments) | ||
| '--remote-debugging-port=9222' // Optional: Allows remote debugging |
There was a problem hiding this comment.
I have copied the karma configuration from the korlibs repo and moved it to each module that needs one, which is a minimal configuration.
However, these flags are used for development / tests, and could proove useful in the future. I would reenable them afterwards if we noticed issues with the workflows.
| api(projects.korge) | ||
| api(libs.kotlinx.benchmark.runtime) |
There was a problem hiding this comment.
Many of our dependencies are added as API dependencies, which are passed down transitively and potentially leak unwanted (re)sources. I would address and discuss this in separate PRs and keep the dependencies for now the same.
|
@malliaridis I realized that then running |
You are right, it is not included because we are using For the publication of the plugins you can and should instead use the module-specific task: ./gradlew :korge-gradle-plugins:korge-gradle-plugin:publishToMavenLocalThe current state / builds of the plugins do not have a version yet (they use And I believe |
|
Should we use a separate release cycle for the plugins and therefore use a different version variable than korge itself from now on, or should it be shared (at least this PR)? |
Thanks, perfect! This is all I need :)
Releasing them separately is OK. I would keep the version in sync for now as long as both come out of the same repo. Later we can decouple the version. But I would suggest that both have the same major version, to keep them aligned. |
Yes, we need to release |
There was a problem hiding this comment.
Version info missing: version = libs.versions.korge.get()
There was a problem hiding this comment.
Shouldn't we change here both places to use Java 25?
There was a problem hiding this comment.
As mentioned in other comment, for higher compatibility, Java 21 may be the better option right now. But I am open to discuss and test an upgrade to 25 as well. :)
There was a problem hiding this comment.
I guess I mixed it up with the need to use/update to Java 25 in Intellij IDEA/Android Studio because of Gradle 9.4.1. But here the Java version means something else, right? So, it's fine to go with Java 21 :)
There was a problem hiding this comment.
The selection of the java version mainly depends on the libraries used in the game projects. When going with the lets say Java 25, any other dependency added to the project needs to support that version as well, otherwise it won't compile. As of today, I believe the highest compatibility is reached with 21, not 25 (yet).
I guess we can upgrade to 25 in the next major release though, or allow the user to configure it (best option) and only fallback to 21 if the user is not interested in setting it. But I would address that outside the scope of this PR.
| //androidTestImplementation 'com.android.support.test:runner:1.0.2' | ||
| } | ||
| private fun Project.configureAndroidExecutable(isKorge: Boolean) { | ||
| project.plugins.apply("com.android.application") |
There was a problem hiding this comment.
It looks like we cannot use this plugin with the new AGP version. Remove line?
There was a problem hiding this comment.
The android application plugin cannot be configured together with the multiplatform plugins. This is the migration requirement for AGP 9.
Just removing the "apply" here would simply not apply the plugin. This would probably break the rest of the configuration in this file. Upgrading AGP. to 9 in 7.0 will require users to also migrate their projects to not use android application plugin in the same module as the multiplatform shared code.
Providing a migration guide is required here.
Whether we need to configure the android executable function though is another topic. I would like to cleanup the korge-plugin, but in a separate move, and remove any configuration that we should not be countable for (e.g. project details that are configured in gradle per project).
This requires some better planning and investigation of what is configured and how in this plugin.
There was a problem hiding this comment.
Upgrading AGP. to 9 in 7.0 will require users to also migrate their projects to not use android application plugin in the same module as the multiplatform shared code.
Korge is "hiding" the Gradle stuff from the (game) developer. So I guess there are not many of us which will have any additional Gradle code outside of Korge in their game project configuration. I even remember that adding another dependency to a library from Maven Central (as I did for Fleks) required to "go" through Korge and use a provided Gradle plugin function dependencyMulti("io.github.quillraven.fleks:Fleks:2.14", registerPlugin = false). So I guess there will not be the need for a migration guide.
If "com.android.application" cannot be used - as it seems - then let's remove it and add what is necessary to get Korge working again :)
There was a problem hiding this comment.
Yeah, this is what I found problematic with the current plugin setup. We are basically "redefining" what gradle already does. We have like an alias for everything just to make it "the korge way", without any special reason. Sure there was or is a reason, but it can definitely be solved differently, more gradle-like, allowing users who already are familiar with gradle use their existing knowledge. So korge would be just another plugin that turns your project into a game, similar to what the compose plugin does (turning your project to a frontend multiplatform application).
There was a problem hiding this comment.
This is a very good point. I would also like that Korge does not add its "own" Gradle stuff. This is hard to understand and to maintain. I am fine if we find a good solution for 7.0.0 (or 8?) which just uses Gradle in a minimalistic way. This also makes maintenance much easier.
When there is already a good approach (compose plugin) than why not utilizing it also for Korge.
There was a problem hiding this comment.
LibraryExtention is deprecated and needs to be exchanged with something else. But I could not figure it out and I could not get it working to use this in a downstream project wiht kproject (e.g. in korlibs/korge-hello-world example).
There was a problem hiding this comment.
The replacement for it is KotlinMultiplatformAndroidLibraryExtension now. I have updated the file accordingly, further deprecations need to be identified and updated. Thanks for finding this one. I will also take a look at other repos once this is no longer in draft state.
| } | ||
| } | ||
| group = "org.korge.engine" | ||
| version = rootProject.libs.versions.korge.get() | ||
|
|
||
| mavenPublishing { | ||
| configure(JavaLibrary(javadocJar = JavadocJar.Empty(), sourcesJar = true)) |
There was a problem hiding this comment.
It looks like we need to change sourcesJar = true so something else?
There was a problem hiding this comment.
I haven't figured out what this line configures yet. I will have to look it up to better understand it. I only took it over from previous configuration. I'll share my findings here.
| javaSourceCompatibility = "21" | ||
| javaTargetCompatibility = "21" |
There was a problem hiding this comment.
25 may be the next LTS, but I have seen some lack of support. So it would probably be too early to go with Java 25.
What would should consider is replacing these two values with toolchain configuration, rather than setting source and target compatibility values (old way setting them).
| [plugins] | ||
| buildconfig = { id = "com.github.gmazzo.buildconfig", version.ref = "buildconfig" } | ||
| android-multiplatform-library = { id = "com.android.kotlin.multiplatform.library", version.ref = "android-gradle-plugin" } | ||
| android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" } |
There was a problem hiding this comment.
android-application is not used or deprecated, so I guess we can remove it?
There was a problem hiding this comment.
android-application is used by :korge-sandbox:androidApp. This plugin is not compatible with the rest of the multiplatform plugins, and causes all the trouble of splitting existing gradle modules into two separate modules.
There was a problem hiding this comment.
korge-sandbox needs to be adjusted also. It uses Korge basically the same (?) way as a standalone Korge game project would use Korge. I guess it can be used to quickly test Korge features without the need of releasing Korge locally and using it in another project.
There was a problem hiding this comment.
You may try the sandbox again and let me know if it works for JVM now. I have enabled and configured a few things to make it work again (tested on MacOS). There are basically 3 executable tasks:
jvmRunrunJvmrunJvmAwtSandbox
|
I put all my findings in comments to not loose them and maybe contribute. They are from trying to get my game project working with |
Description
As we move forward and plan to upgrade our libraries and tools, major releases require larger refactorings. This PR addresses the major upgrade of Gradle to 9.4.1 and Android Gradle Plugin to 9.1.1, as well as korlibs to 7.0.0-SNAPSHOT.
Solution
The current AGP upgrade requires a split of the android application plugin and therefore the android entrypoint. This forces us to split the sandbox module into two modules, one is the shared sandbox stuff, and the other the
androidAppentrypoint module.The PR removes the usage of the complex setup in
buildSrcand follows a more gradle-native approach. The existing pluginskorge-gradle-plugin,korge-gradle-plugin-commonandkorge-gradle-plugin-settingsare moved to a sub-directory and included as composite builds.The
archivedirectory is completely removed, as it is not a meaningful part of the project (it is still available in the git history).The workflows are flattened to clearly distinguish between each os-specific workflow and their tasks. I chose here duplication for readability and simplicity. Multiple tasks are replaced with just
gradlew check.I have compared
buildSrcwith the currentkorge-gradle-plugin. There are minimal differences, and with the move to the composite build, most changes are now identical, withkorge-gradle-plugincontaining more stuff (probably more up-to-date). Therefore, removingbuildSrcseems like removing a whole duplicated module. You can generate a diff with the IDE and see the actual differences listed to confirm this.Open Tasks
Additional Information
Important Note when trying this PR: In order to build and test this PR you have to use Android Studio or Gradle from the CLI. None of the current IntelliJ versions support this build (AGP 9 to be precise) and you have to disable the Android plugin in IntelliJ if you want the Gradle sync to succeed (not tested yet in this project). The AGP versions is not supported, and the proposal of downgrading to 9.0.0-alphaX is not solving the sync issue either. Support for AGP 9 was planned in Q1 of 2026, but we still waiting for it.
Improtant Note 2: To run the checks successfully, you have to use a local publication of korlibs with the changes from korlibs/korlibs#201.
Note that the increase of lines of code comes from the API files. In reality the lines of code are reduced by a lot.