Skip to content
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

Incorporate Kotlin 1.9 deprecations and new features #269

Merged
merged 9 commits into from
Jul 24, 2024

Conversation

garyp
Copy link
Collaborator

@garyp garyp commented Jul 2, 2024

There have been a bunch of features deprecated between Kotlin 1.5.32 and 1.9.24, as well as new features added. Any breaking changes were handled in #259. This PR updates pbandk to remove non-breaking deprecated features and adopt some of the new features. Specifically:

  • Kotlin no longer requires opt-in to the RequiresOptIn annotation
  • Kotlin/Native requires exceptions to be declared for proper Swift interop
  • Run Kotlin as part of the Gradle daemon
  • Migrate examples from the kotlin-js to the kotlin-multiplatform gradle plugin
  • Switch to the new compilerOptions Kotlin Gradle DSL
  • Replace until with the new ..< operator
  • Remove support for the legacy Kotlin/Native memory manager
  • Re-generate all of the generated code
  • Fix gradle task name for publishing to Sonatype

It'll probably be easiest to review this PR by looking at each commit separately since the changes are unrelated to each other. The description of each commit includes more details on each change.

@garyp garyp changed the title garyp/kotlin 1.9 updates Incorporate Kotlin 1.9 deprecations and new features Jul 2, 2024
@garyp garyp force-pushed the garyp/kotlin-1.9-updates branch from 09b60cd to 815d279 Compare July 3, 2024 13:13
@garyp garyp marked this pull request as ready for review July 3, 2024 13:36
@garyp garyp requested a review from kjanderson2 July 3, 2024 13:41
@@ -226,21 +218,19 @@ public open class CodeGenerator(
chunk: List<Pair<File.Field.Numbered, File.Field.OneOf?>>,
fullTypeName: String
) {
line("fieldsList.apply {").indented {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This change only removed the fieldsList.apply { line (and accompanying indentation). The rest of the code didn't change.

@garyp garyp added this to the 0.15.0 milestone Jul 9, 2024
Base automatically changed from garyp/fix-expect-warnings to master July 23, 2024 07:08
`kotlin.compiler.execution.strategy` is no longer supported as a system
property:
https://kotlinlang.org/docs/whatsnew17.html#deprecation-of-the-kotlin-compiler-execution-strategy-system-property.
Furthermore, Gradle docs now recommend running the Gradle daemon even
for CI jobs. As such, might as well try running Kotlin in the Gradle
daemon (the default config) and see if it works better now than it used
to.
The old `kotlinOptions` DSL is deprecated in favor of this new API that
is built on top of gradle properties.
They are exactly equivalent, but the new operator makes the intent of
the code a bit clearer.
Kotlin 1.9.20 removed support for the legacy memory manager:
https://kotlinlang.org/docs/whatsnew1920.html#removal-of-the-legacy-memory-manager.
So we ne longer need to support it within pbandk. The new memory manager
works more similarly to how Kotlin/JVM works, so we can remove a couple
workarounds that were only needed for Kotlin/Native:

1. We no longer need to freeze `AtomicReference` values that will be
shared between threads.

2. The `Message.Companion.descriptor` property on generated message
classes can now be constructed eagerly (i.e. without using `by lazy`)
without the circular references causing problems on Kotlin/Native. I
also cleaned up the code slightly to use the new `buildList()` function
introduced in recent Kotlin versions to build the list of field
descriptors.
This is just the output of running `./gradlew generateProtos` after the
recent changes to `CodeGenerator.kt`.
The full task name ends with `ToSonatypeRepository` rather than just
`ToSonatype`. The previously-used task name is now ambiguous (after some
of the changes made in the PR to update to Kotlin 1.9) and causes gradle
to fail with this error:

```
Task 'publishIosArm64PublicationToSonatype' is ambiguous in root project 'pbandk' and its subprojects. Candidates are: 'publishIosArm64PublicationToSonatypeRepository', 'publishIosSimulatorArm64PublicationToSonatypeRepository'.
```
@garyp garyp merged commit a88ce9c into master Jul 24, 2024
9 checks passed
@garyp garyp deleted the garyp/kotlin-1.9-updates branch July 24, 2024 15:45
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.

None yet

1 participant