Skip to content

Commit 9785d1a

Browse files
authored
Deps: Update Kotlin to 2.1.21 (#389)
* Update Kotlin and Compose version * Missing newline * Update * Update deprecations * Fix K2 compiler issue * Formatting * Fix test * Update * Update * Formatting * Formatting * Fix Java 11 config * Bump test lib versions * Versions * Java config * Update * Enable debug temporarily * Revert * Update * Update * Update * Line end * Formatting * Add toolchain to java block * Update CHANGELOG * Update publication * Update * Update * Update `distZip` task to use the locally published artifacts via `publishToMavenLocal` (#425) * Update * Update * Update * Let CI run for testing * Update * Update * Update * Update * Update * Clean up * Update use maybeCreate always * Update CHANGELOG.md
1 parent f354280 commit 9785d1a

File tree

20 files changed

+146
-278
lines changed

20 files changed

+146
-278
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
Potentially breaking: this release bumps the used Kotlin version to `2.1.21`.
6+
7+
### Dependencies
8+
9+
- Bump Kotlin from `1.9.23` to `2.1.21` ([#389](https://github.com/getsentry/sentry-kotlin-multiplatform/pull/389/))
10+
11+
### Internal
12+
13+
- Update `distZip` task to use the locally published artifacts via `publishToMavenLocal` ([#425](https://github.com/getsentry/sentry-kotlin-multiplatform/pull/425))
14+
315
## 0.15.0
416

517
### Enhancements

build.gradle.kts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ plugins {
1111
id(Config.dokka).version(Config.dokkaVersion)
1212
kotlin(Config.multiplatform).version(Config.kotlinVersion).apply(false)
1313
kotlin(Config.cocoapods).version(Config.kotlinVersion).apply(false)
14-
id(Config.jetpackCompose).version(Config.composeVersion).apply(false)
14+
id(Config.jetpackCompose).version(Config.composePluginVersion).apply(false)
15+
id(Config.kotlinCompose).version(Config.kotlinVersion).apply(false)
1516
id(Config.androidGradle).version(Config.agpVersion).apply(false)
1617
id(Config.BuildPlugins.buildConfig).version(Config.BuildPlugins.buildConfigVersion).apply(false)
1718
kotlin(Config.kotlinSerializationPlugin).version(Config.kotlinVersion).apply(false)
@@ -30,16 +31,19 @@ subprojects {
3031
apply<DistributionPlugin>()
3132

3233
val sep = File.separator
34+
// The path where we want publishToMavenLocal to output the artifacts to
35+
val buildPublishDir = "${project.layout.buildDirectory.get().asFile.path}${sep}sentry-local-publish$sep"
3336

3437
configure<DistributionContainer> {
35-
this.configureForMultiplatform(this@subprojects)
38+
configureForMultiplatform(this@subprojects, buildPublishDir)
3639
}
3740

3841
tasks.named("distZip").configure {
39-
this.dependsOn("publishToMavenLocal")
40-
this.doLast {
42+
System.setProperty("maven.repo.local", buildPublishDir)
43+
dependsOn("publishToMavenLocal")
44+
doLast {
4145
val distributionFilePath =
42-
"${this.project.buildDir}${sep}distributions${sep}${this.project.name}-${this.project.version}.zip"
46+
"${project.layout.buildDirectory.get().asFile.path}${sep}distributions${sep}${project.name}-${project.version}.zip"
4347
val file = File(distributionFilePath)
4448
if (!file.exists()) throw GradleException("Distribution file: $distributionFilePath does not exist")
4549
if (file.length() == 0L) throw GradleException("Distribution file: $distributionFilePath is empty")

buildSrc/src/main/java/Config.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
object Config {
22
val agpVersion = "7.4.2"
3-
val kotlinVersion = "1.9.23"
4-
val composeVersion = "1.6.1"
3+
val kotlinVersion = "2.1.21"
4+
val composePluginVersion = "1.8.0"
55
val gradleMavenPublishPluginVersion = "0.18.0"
66

77
val multiplatform = "multiplatform"
88
val cocoapods = "native.cocoapods"
99
val jetpackCompose = "org.jetbrains.compose"
10+
val kotlinCompose = "org.jetbrains.kotlin.plugin.compose"
1011
val gradleMavenPublishPlugin = "com.vanniktech.maven.publish"
1112
val androidGradle = "com.android.library"
1213
val kotlinSerializationPlugin = "plugin.serialization"
@@ -26,7 +27,7 @@ object Config {
2627
val detekt = "io.gitlab.arturbosch.detekt"
2728
val detektVersion = "1.22.0"
2829
val binaryCompatibility = "org.jetbrains.kotlinx.binary-compatibility-validator"
29-
val binaryCompatibilityVersion = "0.13.1"
30+
val binaryCompatibilityVersion = "0.18.0"
3031
}
3132

3233
object Libs {
@@ -59,9 +60,9 @@ object Config {
5960
val ktorClientOkHttp = "io.ktor:ktor-client-okhttp:2.3.6"
6061
val ktorClientDarwin = "io.ktor:ktor-client-darwin:2.3.6"
6162

62-
val roboelectric = "org.robolectric:robolectric:4.9"
63-
val junitKtx = "androidx.test.ext:junit-ktx:1.1.5"
64-
val mockitoCore = "org.mockito:mockito-core:5.4.0"
63+
val roboelectric = "org.robolectric:robolectric:4.15.1"
64+
val junitKtx = "androidx.test.ext:junit-ktx:1.2.1"
65+
val mockitoCore = "org.mockito:mockito-core:5.18.0"
6566
}
6667

6768
object Android {

buildSrc/src/main/java/Publication.kt

Lines changed: 35 additions & 216 deletions
Original file line numberDiff line numberDiff line change
@@ -1,228 +1,47 @@
1+
import org.gradle.api.GradleException
12
import org.gradle.api.Project
23
import org.gradle.api.distribution.DistributionContainer
3-
import org.gradle.api.file.CopySpec
44
import java.io.File
55

6-
val sep: String = File.separator
6+
private val sep: String = File.separator
77

8-
// configure distZip tasks for multiplatform
9-
fun DistributionContainer.configureForMultiplatform(project: Project) {
10-
val version = project.properties["versionName"].toString()
11-
this.getByName("main").contents {
12-
from("build${sep}publications${sep}kotlinMultiplatform") {
13-
renameModule(project.name, version = version)
14-
}
15-
// The current Kotlin version doesn't generate this *-all.jar anymore.
16-
// This is a placeholder for backwards compatibility with craft until we fix it there directly.
17-
from("build${sep}libs") {
18-
include("${project.name}-metadata-$version*")
19-
rename {
20-
it.replace("metadata-$version", "$version-all")
21-
}
22-
}
23-
from("build${sep}kotlinToolingMetadata") {
24-
rename {
25-
it.replace(
26-
"kotlin-tooling-metadata.json",
27-
"${project.name}-$version-kotlin-tooling-metadata.json"
28-
)
29-
}
30-
}
31-
from("build${sep}libs") {
32-
include("${project.name}-kotlin*")
33-
include("${project.name}-metadata*")
34-
withJavadoc(project.name)
35-
rename {
36-
it.replace("multiplatform-kotlin", "multiplatform").replace("-metadata", "")
37-
}
38-
}
39-
}
40-
this.maybeCreate("android").contents {
41-
from("build${sep}publications${sep}androidRelease") {
42-
renameModule(project.name, "android", version)
43-
}
44-
from("build${sep}outputs${sep}aar${sep}${project.name}-release.aar") {
45-
rename {
46-
it.replace("-release", "-android-release")
47-
}
48-
}
49-
from("build${sep}libs") {
50-
include("*android*")
51-
withJavadoc(project.name, "android")
52-
}
53-
}
54-
this.maybeCreate("jvm").contents {
55-
from("build${sep}publications${sep}jvm") {
56-
renameModule(project.name, "jvm", version)
57-
}
58-
from("build${sep}libs$sep") {
59-
include("*jvm*")
60-
withJavadoc(project.name, "jvm")
61-
}
62-
}
63-
this.maybeCreate("iosarm64").contents {
64-
from("build${sep}publications${sep}iosArm64") {
65-
renameModule(project.name, "iosarm64", version)
66-
}
67-
from("build${sep}libs$sep") {
68-
include("${project.name}-iosarm64*")
69-
withJavadoc(project.name, "iosarm64")
70-
}
71-
fromKlib(project.name, "iosArm64", version)
72-
}
73-
this.maybeCreate("iosx64").contents {
74-
from("build${sep}publications${sep}iosX64") {
75-
renameModule(project.name, "iosx64", version)
76-
}
77-
from("build${sep}libs$sep") {
78-
include("${project.name}-iosx64*")
79-
withJavadoc(project.name, "iosx64")
80-
}
81-
fromKlib(project.name, "iosX64", version)
82-
}
83-
this.maybeCreate("iossimulatorarm64").contents {
84-
from("build${sep}publications${sep}iosSimulatorArm64") {
85-
renameModule(project.name, "iossimulatorarm64", version)
86-
}
87-
from("build${sep}libs$sep") {
88-
include("${project.name}-iossimulatorarm64*")
89-
withJavadoc(project.name, "iossimulatorarm64")
90-
}
91-
fromKlib(project.name, "iosSimulatorArm64", version)
92-
}
93-
this.maybeCreate("macosarm64").contents {
94-
from("build${sep}publications${sep}macosArm64") {
95-
renameModule(project.name, "macosarm64", version)
96-
}
97-
from("build${sep}libs$sep") {
98-
include("${project.name}-macosarm64*")
99-
withJavadoc(project.name, "macosarm64")
100-
}
101-
fromKlib(project.name, "macosArm64", version)
102-
}
103-
this.maybeCreate("macosx64").contents {
104-
from("build${sep}publications${sep}macosX64") {
105-
renameModule(project.name, "macosx64", version)
106-
}
107-
from("build${sep}libs$sep") {
108-
include("${project.name}-macosx64*")
109-
withJavadoc(project.name, "macosx64")
110-
}
111-
fromKlib(project.name, "macosX64", version)
112-
}
113-
this.maybeCreate("watchosx64").contents {
114-
from("build${sep}publications${sep}watchosX64") {
115-
renameModule(project.name, "watchosx64", version)
116-
}
117-
from("build${sep}libs$sep") {
118-
include("${project.name}-watchosx64*")
119-
withJavadoc(project.name, "watchosx64")
120-
}
121-
fromKlib(project.name, "watchosX64", version)
122-
}
123-
this.maybeCreate("watchosarm32").contents {
124-
from("build${sep}publications${sep}watchosArm32") {
125-
renameModule(project.name, "watchosarm32", version)
126-
}
127-
from("build${sep}libs$sep") {
128-
include("${project.name}-watchosarm32*")
129-
withJavadoc(project.name, "watchosarm32")
130-
}
131-
fromKlib(project.name, "watchosArm32", version)
132-
}
133-
this.maybeCreate("watchosarm64").contents {
134-
from("build${sep}publications${sep}watchosArm64") {
135-
renameModule(project.name, "watchosarm64", version)
136-
}
137-
from("build${sep}libs$sep") {
138-
include("${project.name}-watchosarm64*")
139-
withJavadoc(project.name, "watchosarm64")
140-
}
141-
fromKlib(project.name, "watchosArm64", version)
142-
}
143-
this.maybeCreate("watchossimulatorarm64").contents {
144-
from("build${sep}publications${sep}watchosSimulatorArm64") {
145-
renameModule(project.name, "watchossimulatorarm64", version)
146-
}
147-
from("build${sep}libs$sep") {
148-
include("${project.name}-watchossimulatorarm64*")
149-
withJavadoc(project.name, "watchossimulatorarm64")
150-
}
151-
fromKlib(project.name, "watchosSimulatorArm64", version)
152-
}
153-
this.maybeCreate("tvosarm64").contents {
154-
from("build${sep}publications${sep}tvosArm64") {
155-
renameModule(project.name, "tvosarm64", version)
156-
}
157-
from("build${sep}libs$sep") {
158-
include("${project.name}-tvosarm64*")
159-
withJavadoc(project.name, "tvosarm64")
160-
}
161-
fromKlib(project.name, "tvosArm64", version)
162-
}
163-
this.maybeCreate("tvosx64").contents {
164-
from("build${sep}publications${sep}tvosX64") {
165-
renameModule(project.name, "tvosx64", version)
166-
}
167-
from("build${sep}libs$sep") {
168-
include("${project.name}-tvosx64*")
169-
withJavadoc(project.name, "tvosx64")
170-
}
171-
fromKlib(project.name, "tvosX64", version)
172-
}
173-
this.maybeCreate("tvossimulatorarm64").contents {
174-
from("build${sep}publications${sep}tvosSimulatorArm64") {
175-
renameModule(project.name, "tvossimulatorarm64", version)
176-
}
177-
from("build${sep}libs$sep") {
178-
include("${project.name}-tvossimulatorarm64*")
179-
withJavadoc(project.name, "tvossimulatorarm64")
180-
}
181-
fromKlib(project.name, "tvosSimulatorArm64", version)
182-
}
183-
}
8+
fun DistributionContainer.configureForMultiplatform(project: Project, buildPublishDir: String) {
9+
val version = project.property("versionName").toString()
10+
if (version.isEmpty()) {
11+
throw GradleException("DistZip: version name is empty")
12+
}
13+
val projectName = project.name
14+
val platforms = mapOf(
15+
"main" to projectName,
16+
"android" to "$projectName-android",
17+
"jvm" to "$projectName-jvm",
18+
"iosarm64" to "$projectName-iosarm64",
19+
"iossimulatorarm64" to "$projectName-iossimulatorarm64",
20+
"iosx64" to "$projectName-iosx64",
21+
"macosarm64" to "$projectName-macosarm64",
22+
"macosx64" to "$projectName-macosx64",
23+
"tvosarm64" to "$projectName-tvosarm64",
24+
"tvossimulatorarm64" to "$projectName-tvossimulatorarm64",
25+
"tvosx64" to "$projectName-tvosx64",
26+
"watchosarm32" to "$projectName-watchosarm32",
27+
"watchosarm64" to "$projectName-watchosarm64",
28+
"watchossimulatorarm64" to "$projectName-watchossimulatorarm64",
29+
"watchosx64" to "$projectName-watchosx64"
30+
)
18431

185-
private fun CopySpec.fromKlib(projectName: String, target: String, version: String) {
186-
val pos = projectName.length
187-
from("build${sep}classes${sep}kotlin${sep}${target}${sep}main${sep}cinterop") {
188-
include("*.klib")
189-
rename {
190-
it.replaceRange(pos, pos, "-${target.lowercase()}-$version")
191-
}
192-
}
193-
from("build${sep}classes${sep}kotlin${sep}${target}${sep}main${sep}klib") {
194-
rename {
195-
"$projectName-${target.lowercase()}-$version.klib"
196-
}
197-
}
198-
}
32+
platforms.forEach { (distName, projectName) ->
33+
val distribution = maybeCreate(distName)
34+
distribution.contents {
35+
val basePath = "${buildPublishDir}io${sep}sentry${sep}$projectName$sep$version"
19936

200-
private fun CopySpec.renameModule(projectName: String, renameTo: String = "", version: String) {
201-
var target = ""
202-
if (renameTo.isNotEmpty()) {
203-
target = "-$renameTo"
204-
}
205-
rename {
206-
it.replace("module.json", "$projectName$target-$version.module")
207-
}
208-
}
37+
// Rename the POM since craft looks for pom-default.xml
38+
from("$basePath$sep$projectName-$version.pom") {
39+
rename { "pom-default.xml" }
40+
}
20941

210-
private fun CopySpec.withJavadoc(projectName: String, renameTo: String = "") {
211-
include("*javadoc*")
212-
rename { fileName ->
213-
when {
214-
"javadoc" in fileName -> {
215-
val newName = buildString {
216-
append(fileName.substring(0, projectName.length))
217-
if (renameTo.isNotEmpty()) {
218-
append('-')
219-
append(renameTo)
220-
}
221-
append(fileName.substring(projectName.length))
222-
}
223-
newName
42+
from(basePath) {
43+
exclude("*.pom")
22444
}
225-
else -> fileName
22645
}
22746
}
22847
}

sentry-kotlin-multiplatform/api/android/sentry-kotlin-multiplatform.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public abstract class io/sentry/kotlin/multiplatform/SentryBaseEvent {
109109
public fun getUser ()Lio/sentry/kotlin/multiplatform/protocol/User;
110110
public final fun removeTag (Ljava/lang/String;)V
111111
public fun setBreadcrumbs (Ljava/util/List;)V
112+
public final fun setContexts (Ljava/util/Map;)V
112113
public fun setDist (Ljava/lang/String;)V
113114
public fun setEnvironment (Ljava/lang/String;)V
114115
public fun setEventId (Lio/sentry/kotlin/multiplatform/protocol/SentryId;)V

sentry-kotlin-multiplatform/api/jvm/sentry-kotlin-multiplatform.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public abstract class io/sentry/kotlin/multiplatform/SentryBaseEvent {
106106
public fun getUser ()Lio/sentry/kotlin/multiplatform/protocol/User;
107107
public final fun removeTag (Ljava/lang/String;)V
108108
public fun setBreadcrumbs (Ljava/util/List;)V
109+
public final fun setContexts (Ljava/util/Map;)V
109110
public fun setDist (Ljava/lang/String;)V
110111
public fun setEnvironment (Ljava/lang/String;)V
111112
public fun setEventId (Lio/sentry/kotlin/multiplatform/protocol/SentryId;)V

sentry-kotlin-multiplatform/src/androidMain/kotlin/io/sentry/kotlin/multiplatform/SentryPlatformInstance.android.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package io.sentry.kotlin.multiplatform
33
import io.sentry.android.core.SentryAndroid
44

55
internal actual class SentryPlatformInstance : SentryInstance {
6-
override fun init(configuration: PlatformOptionsConfiguration) {
6+
actual override fun init(configuration: PlatformOptionsConfiguration) {
77
val context = applicationContext ?: run {
88
// TODO: add logging later
99
return

sentry-kotlin-multiplatform/src/appleMain/kotlin/io/sentry/kotlin/multiplatform/nsexception/UnhandledExceptionHook.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package io.sentry.kotlin.multiplatform.nsexception
1616

1717
import kotlin.concurrent.AtomicReference
18-
import kotlin.native.concurrent.freeze
1918

2019
/**
2120
* Wraps the unhandled exception hook such that the provided [hook] is invoked
@@ -31,5 +30,5 @@ internal fun wrapUnhandledExceptionHook(hook: (Throwable) -> Unit) {
3130
prevHook.value?.invoke(it)
3231
terminateWithUnhandledException(it)
3332
}
34-
prevHook.value = setUnhandledExceptionHook(wrappedHook.freeze())
33+
prevHook.value = setUnhandledExceptionHook(wrappedHook)
3534
}

0 commit comments

Comments
 (0)