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

Kotlin 2.x #574

Merged
merged 10 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,6 @@ lcp.patch

# direnv file containing Maven Central secrets
.envrc

# Kotlin
.kotlin/
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

| Readium | Android min SDK | Android compile SDK | Kotlin compiler (✻) | Gradle (✻) |
|-----------|-----------------|---------------------|---------------------|------------|
| `develop` | 21 | 35 | 1.9.24 | 8.10.2 |
| `develop` | 21 | 35 | 2.0.21 | 8.10.2 |
| 3.0.0 | 21 | 34 | 1.9.24 | 8.6.0 |
| 2.3.0 | 21 | 33 | 1.7.10 | 6.9.3 |

Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.jetbrains.dokka.gradle.DokkaTaskPartial
plugins {
alias(libs.plugins.dokka)
alias(libs.plugins.ktlint)
alias(libs.plugins.compose.compiler) apply false
}

subprojects {
Expand Down
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ android.useAndroidX=true
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official

# FIXME: There are still a few issues with KSP and K2. It probably won't be ready until Room is
# updated to 2.7.0 (currently in alpha), and the KSP2 issue with @TypeConverters is fixed.
#ksp.useKSP2=true
24 changes: 11 additions & 13 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]

kotlin = "1.9.24"
kotlin = "2.0.21"
agp = "8.7.2"
desugar_jdk_libs = "2.0.4"
gradle-maven-publish-plugin = "0.28.0"
Expand All @@ -10,16 +10,13 @@ androidx-annotation = "1.9.1"
androidx-appcompat = "1.7.0"
androidx-browser = "1.8.0"
androidx-cardview = "1.0.0"
# Make sure to align with the Kotlin version
# https://developer.android.com/jetpack/androidx/releases/compose-kotlin
androidx-compose-compiler = "1.5.14"
androidx-compose-animation = "1.7.5"
androidx-compose-foundation = "1.7.5"
androidx-compose-material = "1.7.5"
androidx-compose-material3 = "1.3.1"
androidx-compose-runtime = "1.7.5"
androidx-compose-ui = "1.7.5"
androidx-constraintlayout = "2.2.0"
androidx-compose-animation = "1.6.7"
androidx-compose-foundation = "1.6.7"
androidx-compose-material = "1.6.7"
androidx-compose-material3 = "1.2.1"
androidx-compose-runtime = "1.6.7"
androidx-compose-ui = "1.6.7"
androidx-constraintlayout = "2.1.4"
androidx-core = "1.15.0"
androidx-datastore = "1.1.1"
androidx-fragment-ktx = "1.8.5"
Expand Down Expand Up @@ -49,11 +46,11 @@ junit = "4.13.2"
kotlinx-coroutines = "1.9.0"
kotlinx-coroutines-test = "1.9.0"
kotlinx-datetime = "0.6.1"
kotlinx-serialization-json = "1.6.3"
kotlinx-serialization-json = "1.7.3"

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

ktlint = "11.5.1"

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

[bundles]

Expand Down
5 changes: 5 additions & 0 deletions readium/lcp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ plugins {

android {
namespace = "org.readium.r2.lcp"

kotlinOptions {
// See https://github.com/readium/kotlin-toolkit/pull/525#issuecomment-2300084041
freeCompilerArgs = freeCompilerArgs + ("-Xconsistent-data-class-copy-visibility")
}
}

dependencies {
Expand Down
5 changes: 5 additions & 0 deletions readium/navigator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ android {
buildFeatures {
viewBinding = true
}

kotlinOptions {
// See https://github.com/readium/kotlin-toolkit/pull/525#issuecomment-2300084041
freeCompilerArgs = freeCompilerArgs + ("-Xconsistent-data-class-copy-visibility")
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ internal class R2WebView(context: Context, attrs: AttributeSet) : R2BasicWebView
}
}

@Deprecated("Deprecated in Java")
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
val count = childCount
val width = r - l
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ public sealed class Url : Parcelable {
* WARNING: Strict URL comparisons can be a source of bug, if the URLs are not normalized.
* In most cases, you should compare using [Url.isEquivalent].
*/
@DelicateReadiumApi
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
Expand Down
4 changes: 1 addition & 3 deletions test-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
kotlin("android")
kotlin("plugin.parcelize")
alias(libs.plugins.ksp)
alias(libs.plugins.compose.compiler)
}

android {
Expand Down Expand Up @@ -37,9 +38,6 @@ android {
jvmTarget = JavaVersion.VERSION_1_8.toString()
freeCompilerArgs = freeCompilerArgs + "-opt-in=kotlin.RequiresOptIn"
}
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get()
}
buildFeatures {
viewBinding = true
compose = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.remember
import androidx.lifecycle.compose.LocalLifecycleOwner
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.lifecycle.flowWithLifecycle
import kotlin.time.Duration
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn

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