Skip to content

Commit d177e72

Browse files
authored
Kotlin 2.x (#574)
1 parent dfb76bc commit d177e72

File tree

12 files changed

+42
-21
lines changed

12 files changed

+42
-21
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,6 @@ lcp.patch
9191

9292
# direnv file containing Maven Central secrets
9393
.envrc
94+
95+
# Kotlin
96+
.kotlin/

.idea/kotlinc.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
| Readium | Android min SDK | Android compile SDK | Kotlin compiler (✻) | Gradle (✻) |
1212
|-----------|-----------------|---------------------|---------------------|------------|
13-
| `develop` | 21 | 35 | 1.9.24 | 8.10.2 |
13+
| `develop` | 21 | 35 | 2.0.21 | 8.10.2 |
1414
| 3.0.0 | 21 | 34 | 1.9.24 | 8.6.0 |
1515
| 2.3.0 | 21 | 33 | 1.7.10 | 6.9.3 |
1616

build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import org.jetbrains.dokka.gradle.DokkaTaskPartial
99
plugins {
1010
alias(libs.plugins.dokka)
1111
alias(libs.plugins.ktlint)
12+
alias(libs.plugins.compose.compiler) apply false
1213
}
1314

1415
subprojects {

gradle.properties

+4
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ android.useAndroidX=true
2727
android.enableJetifier=true
2828
# Kotlin code style for this project: "official" or "obsolete":
2929
kotlin.code.style=official
30+
31+
# FIXME: There are still a few issues with KSP and K2. It probably won't be ready until Room is
32+
# updated to 2.7.0 (currently in alpha), and the KSP2 issue with @TypeConverters is fixed.
33+
#ksp.useKSP2=true

gradle/libs.versions.toml

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[versions]
22

3-
kotlin = "1.9.24"
3+
kotlin = "2.0.21"
44
agp = "8.7.2"
55
desugar_jdk_libs = "2.0.4"
66
gradle-maven-publish-plugin = "0.28.0"
@@ -10,16 +10,13 @@ androidx-annotation = "1.9.1"
1010
androidx-appcompat = "1.7.0"
1111
androidx-browser = "1.8.0"
1212
androidx-cardview = "1.0.0"
13-
# Make sure to align with the Kotlin version
14-
# https://developer.android.com/jetpack/androidx/releases/compose-kotlin
15-
androidx-compose-compiler = "1.5.14"
16-
androidx-compose-animation = "1.7.5"
17-
androidx-compose-foundation = "1.7.5"
18-
androidx-compose-material = "1.7.5"
19-
androidx-compose-material3 = "1.3.1"
20-
androidx-compose-runtime = "1.7.5"
21-
androidx-compose-ui = "1.7.5"
22-
androidx-constraintlayout = "2.2.0"
13+
androidx-compose-animation = "1.6.7"
14+
androidx-compose-foundation = "1.6.7"
15+
androidx-compose-material = "1.6.7"
16+
androidx-compose-material3 = "1.2.1"
17+
androidx-compose-runtime = "1.6.7"
18+
androidx-compose-ui = "1.6.7"
19+
androidx-constraintlayout = "2.1.4"
2320
androidx-core = "1.15.0"
2421
androidx-datastore = "1.1.1"
2522
androidx-fragment-ktx = "1.8.5"
@@ -49,11 +46,11 @@ junit = "4.13.2"
4946
kotlinx-coroutines = "1.9.0"
5047
kotlinx-coroutines-test = "1.9.0"
5148
kotlinx-datetime = "0.6.1"
52-
kotlinx-serialization-json = "1.6.3"
49+
kotlinx-serialization-json = "1.7.3"
5350

5451
# Make sure to align with the Kotlin version.
5552
# See https://github.com/google/ksp/releases
56-
ksp = "1.9.24-1.0.20"
53+
ksp = "2.0.21-1.0.25"
5754

5855
ktlint = "11.5.1"
5956

@@ -150,6 +147,7 @@ kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", versi
150147
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
151148
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
152149
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
150+
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
153151

154152
[bundles]
155153

readium/lcp/build.gradle.kts

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ plugins {
1111

1212
android {
1313
namespace = "org.readium.r2.lcp"
14+
15+
kotlinOptions {
16+
// See https://github.com/readium/kotlin-toolkit/pull/525#issuecomment-2300084041
17+
freeCompilerArgs = freeCompilerArgs + ("-Xconsistent-data-class-copy-visibility")
18+
}
1419
}
1520

1621
dependencies {

readium/navigator/build.gradle.kts

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ android {
1515
buildFeatures {
1616
viewBinding = true
1717
}
18+
19+
kotlinOptions {
20+
// See https://github.com/readium/kotlin-toolkit/pull/525#issuecomment-2300084041
21+
freeCompilerArgs = freeCompilerArgs + ("-Xconsistent-data-class-copy-visibility")
22+
}
1823
}
1924

2025
dependencies {

readium/navigator/src/main/java/org/readium/r2/navigator/R2WebView.kt

+1
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ internal class R2WebView(context: Context, attrs: AttributeSet) : R2BasicWebView
481481
}
482482
}
483483

484+
@Deprecated("Deprecated in Java")
484485
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
485486
val count = childCount
486487
val width = r - l

readium/shared/src/main/java/org/readium/r2/shared/util/Url.kt

-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ public sealed class Url : Parcelable {
205205
* WARNING: Strict URL comparisons can be a source of bug, if the URLs are not normalized.
206206
* In most cases, you should compare using [Url.isEquivalent].
207207
*/
208-
@DelicateReadiumApi
209208
override fun equals(other: Any?): Boolean {
210209
if (this === other) return true
211210
if (javaClass != other?.javaClass) return false

test-app/build.gradle.kts

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ plugins {
99
kotlin("android")
1010
kotlin("plugin.parcelize")
1111
alias(libs.plugins.ksp)
12+
alias(libs.plugins.compose.compiler)
1213
}
1314

1415
android {
@@ -37,9 +38,6 @@ android {
3738
jvmTarget = JavaVersion.VERSION_1_8.toString()
3839
freeCompilerArgs = freeCompilerArgs + "-opt-in=kotlin.RequiresOptIn"
3940
}
40-
composeOptions {
41-
kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get()
42-
}
4341
buildFeatures {
4442
viewBinding = true
4543
compose = true

test-app/src/main/java/org/readium/r2/testapp/utils/extensions/Flow.kt

+9-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@ import androidx.compose.runtime.Composable
1010
import androidx.compose.runtime.State
1111
import androidx.compose.runtime.collectAsState
1212
import androidx.compose.runtime.remember
13-
import androidx.lifecycle.compose.LocalLifecycleOwner
13+
import androidx.compose.ui.platform.LocalLifecycleOwner
1414
import androidx.lifecycle.flowWithLifecycle
1515
import kotlin.time.Duration
1616
import kotlinx.coroutines.CoroutineScope
1717
import kotlinx.coroutines.delay
18-
import kotlinx.coroutines.flow.*
18+
import kotlinx.coroutines.flow.Flow
19+
import kotlinx.coroutines.flow.SharingStarted
20+
import kotlinx.coroutines.flow.StateFlow
21+
import kotlinx.coroutines.flow.conflate
22+
import kotlinx.coroutines.flow.first
23+
import kotlinx.coroutines.flow.flow
24+
import kotlinx.coroutines.flow.map
25+
import kotlinx.coroutines.flow.stateIn
1926

2027
/**
2128
* Collects safely the [Flow] as a [State] when the local lifecycle is started.

0 commit comments

Comments
 (0)