yairm210 / Unciv

Open-source Android/Desktop remake of Civ V
Mozilla Public License 2.0
8.39k stars 1.56k forks source link

FYI: Keeping up with kotlin and gradle versions #11870

Open SomeTroglodyte opened 3 months ago

SomeTroglodyte commented 3 months ago

Log

For kicks I just tried the following:

Tools - AGP Upgrade Assistant...
  Let it do its thing to 8.4.2
`./gradlew wrapper --gradle-version 8.8`
File - Settings - Other Settings - Kotlin Compiler
  Change Kotlin compiler version to 1.9.24
Edit buildScr/src/main/kotlin/BuildConfig.kt:
    `const val kotlinVersion = "1.9.24"`
    `const val ktorVersion = "2.3.12"`
    `const val coroutinesVersion = "1.8.1"`
Let gradle sync do its stuff
Run desktop config - works
Run on some android device - works

`rm -rf .gradle/8.2`
`rm -rf ~/.gradle/caches/8.2`
`rm -rf ~/.gradle/daemon/8.2`
`rm -rf ~/.gradle/wrapper/dists/gradle-8.2-bin`
// AGP will pull a lot of gradle 8.6 crud before we replace that
`rm -rf .gradle/8.6`
`rm -rf ~/.gradle/caches/8.6`
`rm -rf ~/.gradle/daemon/8.6`
`rm -rf ~/.gradle/wrapper/dists/gradle-8.6-bin`
(or maybe rm -rf ~/.gradle/ and endure a redownload of all dependencies to get rid of old libraries)

Alternative Approaches

Wait for kotlin 2 > 2.0.0 and gradle 9?

References

https://ktor.io/docs/releases.html#release-details https://github.com/Kotlin/kotlinx.coroutines/releases

yairm210 commented 3 months ago

Kotlin version - definitely yes

AGP version - we'll need to check I prefer to stick to versions supported by IDEA as well as Android Studio, it has distinct advantages in e.g. performance profiling

SomeTroglodyte commented 3 months ago

Those versions are: AGP is exactly the one offered by Jellyfish-patch2 automatically - haven't upgraded to Koala yet, as usual not trusting it until it has a patch1. Gradle: that AGP plugin chooses 8.6 as new default - or rather needs 8.6 as minimum to install, but also has 8.8 in its offered list, so I chose that version manually - because auto won't upgrade everything, but that gradle wrapper call does include the wrapper jar itself. Why exactly I didn't choose 9 - the argument "too fresh, and might necessitate major build script updates" is already sufficient, but I think AGP didn't offer 9 yet too.

This was FYI so you know I did the experiment and it was relatively painless. I can redo it and wrap as PR - you decide when. But keep in mind all devs pulling that version will need a bit of local maintenance - the kotlin compiler version in settings (that val only determines kotlin-gradle-plugin and kotlin-reflect judging from Alt-F7), possibly a manual gradle sync, optional cache cleanup, one longer gradle sync than usual.

AGP 8.2 was november 2023, so we're not that far behind. We could even up the Compile SDK one level without changing AGP, only for the current preview we'd need more.

Also: Project structure - suggestions shows a few other libraries have newer versions: androidx.core:core-ktx, androidx.work:work-runtime-ktx and com.android.tools:desugar_jdk_libs - I did not test upgrading those, as I'm not really sure where one would see their effect, mostly the work runtime, the other two I'd expect are already tested when one can debug-run android.

For a real PR I would probably also check first whether Koala would go to a different AGP (8.5 is out, its release notes say yes Koala would use that one), then think hard on whether it would be preferable or not.

github-actions[bot] commented 5 days ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 15 days.