Skip to content

Deps: Update Kotlin to 2.1.21 #389

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

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3d0f8f1
Update Kotlin and Compose version
buenaflor May 16, 2025
5938aac
Missing newline
buenaflor May 16, 2025
39775b7
Update
buenaflor May 16, 2025
ef0aa9c
Update deprecations
buenaflor May 16, 2025
8db72ee
Merge branch 'main' into deps/upgrade-kotlin
buenaflor Jun 25, 2025
530cdf0
Fix K2 compiler issue
buenaflor Jun 27, 2025
305871a
Formatting
buenaflor Jun 27, 2025
cd22321
Fix test
buenaflor Jun 27, 2025
c893986
Update
buenaflor Jun 27, 2025
c856bd6
Update
buenaflor Jun 27, 2025
1e18595
Formatting
buenaflor Jun 27, 2025
23b0ea4
Formatting
buenaflor Jun 27, 2025
e0b6d23
Fix Java 11 config
buenaflor Jun 27, 2025
eecc548
Bump test lib versions
buenaflor Jun 27, 2025
2115539
Versions
buenaflor Jun 27, 2025
1f1a4f6
Java config
buenaflor Jun 27, 2025
e611075
Update
buenaflor Jun 27, 2025
9d5ba95
Merge branch 'main' into deps/upgrade-kotlin
buenaflor Jun 27, 2025
f8c356c
Enable debug temporarily
buenaflor Jun 27, 2025
43ee73a
Revert
buenaflor Jun 27, 2025
0223f5c
Update
buenaflor Jun 27, 2025
fdf6fea
Update
buenaflor Jun 27, 2025
e9c65fd
Update
buenaflor Jun 27, 2025
a5e2d88
Line end
buenaflor Jun 28, 2025
2b5af1f
Formatting
buenaflor Jun 28, 2025
c835f21
Merge branch 'main' into deps/upgrade-kotlin
buenaflor Jun 30, 2025
e0f9abe
Merge branch 'main' into deps/upgrade-kotlin
buenaflor Jul 1, 2025
31e24c6
Add toolchain to java block
buenaflor Jul 4, 2025
0cbb440
Update CHANGELOG
buenaflor Jul 4, 2025
737dade
Update publication
buenaflor Jul 16, 2025
06a6695
Update
buenaflor Jul 17, 2025
b1d21e5
Update
buenaflor Jul 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Dependencies

- Bump Kotlin from `1.9.23` to `2.1.21` ([#389](https://github.com/getsentry/sentry-kotlin-multiplatform/pull/389/))
- Bump Cocoa SDK from v8.49.1 to v8.53.1 ([#405](https://github.com/getsentry/sentry-kotlin-multiplatform/pull/405))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8531)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.49.1...8.53.1)
Expand Down
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ plugins {
id(Config.dokka).version(Config.dokkaVersion)
kotlin(Config.multiplatform).version(Config.kotlinVersion).apply(false)
kotlin(Config.cocoapods).version(Config.kotlinVersion).apply(false)
id(Config.jetpackCompose).version(Config.composeVersion).apply(false)
id(Config.jetpackCompose).version(Config.composePluginVersion).apply(false)
id(Config.kotlinCompose).version(Config.kotlinVersion).apply(false)
id(Config.androidGradle).version(Config.agpVersion).apply(false)
id(Config.BuildPlugins.buildConfig).version(Config.BuildPlugins.buildConfigVersion).apply(false)
kotlin(Config.kotlinSerializationPlugin).version(Config.kotlinVersion).apply(false)
Expand Down
13 changes: 7 additions & 6 deletions buildSrc/src/main/java/Config.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
object Config {
val agpVersion = "7.4.2"
val kotlinVersion = "1.9.23"
val composeVersion = "1.6.1"
val kotlinVersion = "2.1.21"
val composePluginVersion = "1.8.0"
val gradleMavenPublishPluginVersion = "0.18.0"

val multiplatform = "multiplatform"
val cocoapods = "native.cocoapods"
val jetpackCompose = "org.jetbrains.compose"
val kotlinCompose = "org.jetbrains.kotlin.plugin.compose"
val gradleMavenPublishPlugin = "com.vanniktech.maven.publish"
val androidGradle = "com.android.library"
val kotlinSerializationPlugin = "plugin.serialization"
Expand All @@ -26,7 +27,7 @@ object Config {
val detekt = "io.gitlab.arturbosch.detekt"
val detektVersion = "1.22.0"
val binaryCompatibility = "org.jetbrains.kotlinx.binary-compatibility-validator"
val binaryCompatibilityVersion = "0.13.1"
val binaryCompatibilityVersion = "0.18.0"
}

object Libs {
Expand Down Expand Up @@ -59,9 +60,9 @@ object Config {
val ktorClientOkHttp = "io.ktor:ktor-client-okhttp:2.3.6"
val ktorClientDarwin = "io.ktor:ktor-client-darwin:2.3.6"

val roboelectric = "org.robolectric:robolectric:4.9"
val junitKtx = "androidx.test.ext:junit-ktx:1.1.5"
val mockitoCore = "org.mockito:mockito-core:5.4.0"
val roboelectric = "org.robolectric:robolectric:4.15.1"
val junitKtx = "androidx.test.ext:junit-ktx:1.2.1"
val mockitoCore = "org.mockito:mockito-core:5.18.0"
}

object Android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public abstract class io/sentry/kotlin/multiplatform/SentryBaseEvent {
public fun getUser ()Lio/sentry/kotlin/multiplatform/protocol/User;
public final fun removeTag (Ljava/lang/String;)V
public fun setBreadcrumbs (Ljava/util/List;)V
public final fun setContexts (Ljava/util/Map;)V
public fun setDist (Ljava/lang/String;)V
public fun setEnvironment (Ljava/lang/String;)V
public fun setEventId (Lio/sentry/kotlin/multiplatform/protocol/SentryId;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public abstract class io/sentry/kotlin/multiplatform/SentryBaseEvent {
public fun getUser ()Lio/sentry/kotlin/multiplatform/protocol/User;
public final fun removeTag (Ljava/lang/String;)V
public fun setBreadcrumbs (Ljava/util/List;)V
public final fun setContexts (Ljava/util/Map;)V
public fun setDist (Ljava/lang/String;)V
public fun setEnvironment (Ljava/lang/String;)V
public fun setEventId (Lio/sentry/kotlin/multiplatform/protocol/SentryId;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package io.sentry.kotlin.multiplatform
import io.sentry.android.core.SentryAndroid

internal actual class SentryPlatformInstance : SentryInstance {
override fun init(configuration: PlatformOptionsConfiguration) {
actual override fun init(configuration: PlatformOptionsConfiguration) {
val context = applicationContext ?: run {
// TODO: add logging later
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package io.sentry.kotlin.multiplatform.nsexception

import kotlin.concurrent.AtomicReference
import kotlin.native.concurrent.freeze

/**
* Wraps the unhandled exception hook such that the provided [hook] is invoked
Expand All @@ -31,5 +30,5 @@ internal fun wrapUnhandledExceptionHook(hook: (Throwable) -> Unit) {
prevHook.value?.invoke(it)
terminateWithUnhandledException(it)
}
prevHook.value = setUnhandledExceptionHook(wrappedHook.freeze())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

freeze() is deprecated / not needed anymore in this kotlin version

prevHook.value = setUnhandledExceptionHook(wrappedHook)
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public abstract class SentryBaseEvent(
* This is not thread-safe.
*/
public var contexts: Map<String, Any> = mapOf()
internal set
Comment on lines 46 to -47
Copy link
Contributor Author

@buenaflor buenaflor Jun 27, 2025

Choose a reason for hiding this comment

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

internal set was what messed up the K2 compiler when compiling for native targets. admittedly I have no idea why but it compiles without it 😅


/**
* A mutable map of breadcrumbs that led to this event.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ internal interface SentryInstance {
/**
* Represents the actual Sentry SDK instance.
*/
internal expect class SentryPlatformInstance() : SentryInstance
internal expect class SentryPlatformInstance() : SentryInstance {
override fun init(configuration: PlatformOptionsConfiguration)
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SentryE2ETest : BaseSentryTest() {
@BeforeTest
fun setup() {
assertNotNull(authToken)
assertTrue(authToken.isNotEmpty())
assertTrue(authToken!!.isNotEmpty())
sentryInit { options ->
options.dsn = realDsn
options.beforeSend = { event ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package io.sentry.kotlin.multiplatform
import cocoapods.Sentry.SentrySDK

internal actual class SentryPlatformInstance : SentryInstance {
override fun init(configuration: PlatformOptionsConfiguration) {
actual override fun init(configuration: PlatformOptionsConfiguration) {
val finalConfiguration: (CocoaSentryOptions?) -> Unit = {
if (it != null) {
configuration(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package io.sentry.kotlin.multiplatform
import cocoapods.Sentry.SentrySDK

internal actual class SentryPlatformInstance : SentryInstance {
override fun init(configuration: PlatformOptionsConfiguration) {
actual override fun init(configuration: PlatformOptionsConfiguration) {
val finalConfiguration: (CocoaSentryOptions?) -> Unit = {
if (it != null) {
configuration(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package io.sentry.kotlin.multiplatform
import io.sentry.Sentry as JvmSentry

internal actual class SentryPlatformInstance : SentryInstance {
override fun init(configuration: PlatformOptionsConfiguration) {
actual override fun init(configuration: PlatformOptionsConfiguration) {
JvmSentry.init(configuration)
}
}
20 changes: 15 additions & 5 deletions sentry-samples/kmp-app-cocoapods/androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id("com.android.application")
Expand All @@ -7,6 +7,10 @@ plugins {
}

android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
compileSdk = Config.Android.compileSdkVersion
defaultConfig {
applicationId = "sample.kmp.app.android"
Expand Down Expand Up @@ -34,12 +38,18 @@ android {
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11

toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_11
}
}

dependencies {
Expand Down
16 changes: 8 additions & 8 deletions sentry-samples/kmp-app-cocoapods/desktopApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
kotlin("multiplatform")
id("org.jetbrains.kotlin.plugin.compose")
id("org.jetbrains.compose")
}

Expand All @@ -16,17 +17,16 @@ repositories {
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}

kotlin {
jvm {
withJava()
compilerOptions {
jvmTarget = JvmTarget.JVM_11
}
}
sourceSets {
val jvmMain by getting {
Expand Down
21 changes: 13 additions & 8 deletions sentry-samples/kmp-app-cocoapods/shared/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
kotlin("multiplatform")
Expand All @@ -8,19 +8,20 @@ plugins {
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}

kotlin {
applyDefaultHierarchyTemplate()

androidTarget()
jvm()
jvm {
compilerOptions {
jvmTarget = JvmTarget.JVM_11
}
}
iosX64()
iosArm64()
iosSimulatorArm64()
Expand Down Expand Up @@ -59,6 +60,10 @@ kotlin {
}

android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
compileSdk = Config.Android.compileSdkVersion
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
Expand Down
20 changes: 15 additions & 5 deletions sentry-samples/kmp-app-spm/androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id("com.android.application")
Expand All @@ -7,15 +7,25 @@ plugins {
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11

toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_11
}
}

android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
compileSdk = Config.Android.compileSdkVersion
defaultConfig {
applicationId = "sample.kmp.app.android"
Expand Down
16 changes: 8 additions & 8 deletions sentry-samples/kmp-app-spm/desktopApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
kotlin("multiplatform")
id("org.jetbrains.kotlin.plugin.compose")
id("org.jetbrains.compose")
}

Expand All @@ -16,17 +17,16 @@ repositories {
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}

kotlin {
jvm {
withJava()
compilerOptions {
jvmTarget = JvmTarget.JVM_11
}
}
sourceSets {
val jvmMain by getting {
Expand Down
21 changes: 13 additions & 8 deletions sentry-samples/kmp-app-spm/shared/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
kotlin("multiplatform")
Expand All @@ -7,19 +7,20 @@ plugins {
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}

kotlin {
applyDefaultHierarchyTemplate()

androidTarget()
jvm()
jvm {
compilerOptions {
jvmTarget = JvmTarget.JVM_11
}
}
listOf(
iosX64(),
iosArm64(),
Expand All @@ -44,6 +45,10 @@ kotlin {
}

android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
compileSdk = Config.Android.compileSdkVersion
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
Expand Down
Loading