Skip to content

Commit 9c64892

Browse files
authored
Update to Kotlin 1.9.22 (#185)
* Update to Kotlin 1.9.22 * ~ cleanup buildscript
1 parent 7f6515b commit 9c64892

File tree

12 files changed

+165
-78
lines changed

12 files changed

+165
-78
lines changed

gradle/libs.versions.toml

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
[versions]
2-
kotlin = "1.9.10"
2+
kotlin = "1.9.22"
33
dokka = "1.9.10"
4-
agp = "8.1.2"
4+
agp = "8.2.0"
55
coroutines = "1.7.3"
66
guava = "31.0.1-android"
77
awaitility = "4.2.0"
8-
atomicfu = "0.22.0"
8+
atomicfu = "0.23.1"
99
binary_compat = "0.13.2"
10-
kover = "0.7.4"
10+
kover = "0.7.5"
1111
slf4j = "2.0.9"
12-
ksp = "1.9.10-1.0.13"
13-
kotlinpoet = "1.14.2"
12+
ksp = "1.9.22-1.0.17"
13+
kotlinpoet = "1.15.3"
1414
ax_lifecycle = "2.6.2"
1515
ax_testing = "2.2.0"
1616
ax_runner = "1.5.2"
17-
robolectric = "4.10.3"
17+
robolectric = "4.11.1"
1818
turbine = "1.0.0"
19-
compose_compiler = "1.5.3"
20-
compose_multiplatform = "1.5.3"
21-
compose_multiplatform_compiler = "1.5.0"
19+
compose_compiler = "1.5.8"
20+
compose_multiplatform = "1.5.11"
21+
compose_multiplatform_compiler = "1.5.7.1"
22+
androidxComposeBom = "2023.10.01"
2223

2324
[plugins]
2425
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
2526
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
2627
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
2728
binaryCompat = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binary_compat" }
2829
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
29-
mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.25.3" }
30+
mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.26.0" }
3031
composeMultiplatform = { id = "org.jetbrains.compose", version.ref = "compose_multiplatform" }
3132

3233
[libraries]

mobiuskt-compose/build.gradle.kts

+6-2
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,22 @@ android {
3535
}
3636
}
3737

38+
compose {
39+
kotlinCompilerPlugin.set(libs.versions.compose.multiplatform.compiler.get())
40+
}
41+
3842
kotlin {
3943
androidTarget()
4044
jvm {
4145
jvmToolchain(11)
4246
}
4347
js(IR) {
4448
browser {
45-
testTask(Action {
49+
testTask {
4650
useKarma {
4751
useFirefoxHeadless()
4852
}
49-
})
53+
}
5054
}
5155
}
5256
listOf(

mobiuskt-core/build.gradle.kts

+22-35
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
apply(plugin = "kotlinx-atomicfu")
1010

1111
android {
12-
compileSdk = 33
12+
compileSdk = 34
1313
namespace = "kt.mobius.android"
1414
defaultConfig {
1515
minSdk = 21
@@ -37,6 +37,9 @@ android {
3737
}
3838

3939
kotlin {
40+
compilerOptions {
41+
freeCompilerArgs.add("-Xexpect-actual-classes")
42+
}
4043
androidTarget {
4144
jvmToolchain(11)
4245
publishLibraryVariants("release", "debug")
@@ -48,45 +51,31 @@ kotlin {
4851
binaries.library()
4952
nodejs()
5053
browser {
51-
testTask(Action {
54+
testTask {
5255
useKarma {
5356
useFirefoxHeadless()
5457
}
55-
})
56-
}
57-
}
58-
59-
val nativeTargets = listOf(
60-
iosX64(),
61-
iosArm64(),
62-
iosSimulatorArm64(),
63-
tvosX64(),
64-
tvosArm64(),
65-
tvosSimulatorArm64(),
66-
watchosArm32(),
67-
watchosArm64(),
68-
watchosSimulatorArm64(),
69-
watchosDeviceArm64(),
70-
watchosX64(),
71-
macosX64(),
72-
macosArm64(),
73-
linuxX64(),
74-
linuxArm64(),
75-
mingwX64(),
76-
)
77-
val darwinTargets = listOf("ios", "tvos", "watchos", "macos")
78-
configure(nativeTargets) {
79-
compilations.getByName("main") {
80-
defaultSourceSet {
81-
kotlin.srcDir("src/nativeMain/kotlin")
82-
83-
if (darwinTargets.any(this@configure.name::startsWith)) {
84-
kotlin.srcDir("src/darwinMain/kotlin")
85-
}
8658
}
8759
}
8860
}
8961

62+
iosX64()
63+
iosArm64()
64+
iosSimulatorArm64()
65+
tvosX64()
66+
tvosArm64()
67+
tvosSimulatorArm64()
68+
watchosArm32()
69+
watchosArm64()
70+
watchosSimulatorArm64()
71+
watchosDeviceArm64()
72+
watchosX64()
73+
macosX64()
74+
macosArm64()
75+
linuxX64()
76+
linuxArm64()
77+
mingwX64()
78+
9079
sourceSets {
9180
all {
9281
explicitApi()
@@ -123,15 +112,13 @@ kotlin {
123112
}
124113

125114
val androidMain by getting {
126-
dependsOn(jvmMain)
127115
dependencies {
128116
implementation(libs.androidx.livedata)
129117
implementation(libs.androidx.viewmodel)
130118
}
131119
}
132120

133121
val androidUnitTest by getting {
134-
dependsOn(jvmTest)
135122
dependencies {
136123
implementation(projects.mobiusktTest)
137124
implementation(libs.androidx.lifecycleRuntime)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package kt.mobius.runners
2+
3+
import kt.mobius.functions.Producer
4+
import java.util.concurrent.Executors
5+
import java.util.concurrent.ThreadFactory
6+
import java.util.concurrent.atomic.AtomicLong
7+
8+
internal actual object DefaultWorkRunners {
9+
private val threadFactory = MyThreadFactory()
10+
11+
actual fun eventWorkRunnerProducer() = Producer {
12+
WorkRunners.from(Executors.newSingleThreadExecutor(threadFactory))
13+
}
14+
15+
actual fun effectWorkRunnerProducer() = Producer {
16+
WorkRunners.from(Executors.newCachedThreadPool(threadFactory))
17+
}
18+
19+
private class MyThreadFactory : ThreadFactory {
20+
private val threadCount = AtomicLong(0)
21+
22+
override fun newThread(r: java.lang.Runnable): Thread {
23+
return Executors.defaultThreadFactory().newThread(r).apply {
24+
name = "mobius-thread-${threadCount.incrementAndGet()}"
25+
}
26+
}
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package kt.mobius.runners
2+
3+
import kotlinx.atomicfu.locks.withLock
4+
import kt.mobius.MobiusHooks
5+
import java.util.concurrent.ExecutorService
6+
import java.util.concurrent.TimeUnit
7+
import java.util.concurrent.locks.ReentrantLock
8+
9+
/** A [WorkRunner] implementation that is backed by an [ExecutorService]. */
10+
public class ExecutorServiceWorkRunner(private val service: ExecutorService) : WorkRunner {
11+
12+
private val logger = MobiusHooks.newLogger("ExecutorServiceWorkRunner")
13+
private val lock = ReentrantLock()
14+
15+
override fun post(runnable: Runnable) {
16+
lock.withLock {
17+
if (!service.isTerminated && !service.isShutdown) {
18+
service.submit(runnable)
19+
}
20+
}
21+
}
22+
23+
override fun dispose() {
24+
try {
25+
lock.withLock {
26+
val runnables = service.shutdownNow()
27+
28+
if (runnables.isNotEmpty()) {
29+
logger.warn("Disposing ExecutorServiceWorkRunner with {} outstanding tasks.", runnables.size)
30+
}
31+
}
32+
33+
if (!service.awaitTermination(100, TimeUnit.MILLISECONDS)) {
34+
logger.error("ExecutorService shutdown timed out; there are still tasks executing")
35+
}
36+
} catch (e: InterruptedException) {
37+
logger.error(e, "Timeout when disposing work runner")
38+
}
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package kt.mobius.runners
2+
3+
public actual typealias Runnable = java.lang.Runnable
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package kt.mobius.runners
2+
3+
4+
import java.util.concurrent.ExecutorService
5+
import java.util.concurrent.Executors
6+
7+
public actual object WorkRunners {
8+
9+
@JvmStatic
10+
public actual fun immediate(): WorkRunner {
11+
return ImmediateWorkRunner()
12+
}
13+
14+
@JvmStatic
15+
public fun singleThread(): WorkRunner {
16+
return from(Executors.newSingleThreadExecutor())
17+
}
18+
19+
@JvmStatic
20+
public fun fixedThreadPool(n: Int): WorkRunner {
21+
return from(Executors.newFixedThreadPool(n))
22+
}
23+
24+
@JvmStatic
25+
public fun cachedThreadPool(): WorkRunner {
26+
return from(Executors.newCachedThreadPool())
27+
}
28+
29+
@JvmStatic
30+
public fun from(service: ExecutorService): WorkRunner {
31+
return ExecutorServiceWorkRunner(service)
32+
}
33+
}

mobiuskt-coroutines/build.gradle.kts

+17-26
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,29 @@ kotlin {
1515
binaries.executable()
1616
nodejs()
1717
browser {
18-
testTask(Action {
18+
testTask {
1919
useKarma {
2020
useFirefoxHeadless()
2121
}
22-
})
23-
}
24-
}
25-
val nativeTargets = listOf(
26-
iosX64(),
27-
iosArm64(),
28-
iosSimulatorArm64(),
29-
tvosX64(),
30-
tvosArm64(),
31-
tvosSimulatorArm64(),
32-
watchosArm32(),
33-
watchosArm64(),
34-
watchosSimulatorArm64(),
35-
watchosDeviceArm64(),
36-
watchosX64(),
37-
macosX64(),
38-
macosArm64(),
39-
linuxX64(),
40-
linuxArm64(),
41-
mingwX64(),
42-
)
43-
configure(nativeTargets) {
44-
compilations.getByName("test") {
45-
defaultSourceSet {
46-
kotlin.srcDir("src/nativeTest/kotlin")
4722
}
4823
}
4924
}
25+
iosX64()
26+
iosArm64()
27+
iosSimulatorArm64()
28+
tvosX64()
29+
tvosArm64()
30+
tvosSimulatorArm64()
31+
watchosArm32()
32+
watchosArm64()
33+
watchosSimulatorArm64()
34+
watchosDeviceArm64()
35+
watchosX64()
36+
macosX64()
37+
macosArm64()
38+
linuxX64()
39+
linuxArm64()
40+
mingwX64()
5041
sourceSets {
5142
all {
5243
explicitApi()

mobiuskt-extras/build.gradle.kts

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ kotlin {
2626
binaries.library()
2727
nodejs()
2828
browser {
29-
testTask(Action {
29+
testTask {
3030
useKarma {
3131
useFirefoxHeadless()
3232
}
33-
})
33+
}
3434
}
3535
}
3636

mobiuskt-test/build.gradle.kts

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ kotlin {
2828
js(IR) {
2929
nodejs()
3030
browser {
31-
testTask(Action {
31+
testTask {
3232
useKarma {
3333
useFirefoxHeadless()
3434
}
35-
})
35+
}
3636
}
3737
}
3838

0 commit comments

Comments
 (0)