From 46003ec25139319079abc9fde89b3afd344a1a11 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 03:48:35 +0600 Subject: [PATCH] chore(deps): update kotlin and compose compiler to v2 (major) (#819) * chore(deps): update kotlin and compose compiler to v2 * Update .gitignore * Fix build --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> --- .github/renovate.json5 | 8 --- .gitignore | 1 + app/build.gradle.kts | 2 +- buildSrc/build.gradle.kts | 10 +-- ...hon.android.application.compose.gradle.kts | 1 - .../kotlin/mihon/buildlogic/AndroidConfig.kt | 4 ++ .../mihon/buildlogic/ProjectExtensions.kt | 70 +++++++++---------- data/build.gradle.kts | 2 +- domain/build.gradle.kts | 2 +- gradle/compose.versions.toml | 3 - gradle/kotlinx.versions.toml | 4 +- i18n/build.gradle.kts | 2 +- presentation-core/build.gradle.kts | 2 +- source-api/build.gradle.kts | 2 +- source-local/build.gradle.kts | 2 +- .../tachiyomi/source/local/LocalSource.kt | 13 ++-- 16 files changed, 61 insertions(+), 67 deletions(-) diff --git a/.github/renovate.json5 b/.github/renovate.json5 index cc1468ce2..c01f918f5 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -9,14 +9,6 @@ "dev.chrisbanes.compose:compose-bom" ], "ignoreUnstable": false - }, - { - "groupName": "Kotlin and Compose Compiler", - "matchPackagePrefixes": [ - "androidx.compose.compiler", - "org.jetbrains.kotlin.", - "org.jetbrains.kotlin:", - ], } ] } diff --git a/.gitignore b/.gitignore index 6abb1d29e..70e152f0a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .gradle +.kotlin /local.properties /.idea/workspace.xml .DS_Store diff --git a/app/build.gradle.kts b/app/build.gradle.kts index f7f9a78a3..622715259 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -274,7 +274,7 @@ androidComponents { tasks { // See https://kotlinlang.org/docs/reference/experimental.html#experimental-status-of-experimental-api(-markers) withType { - kotlinOptions.freeCompilerArgs += listOf( + compilerOptions.freeCompilerArgs.addAll( "-Xcontext-receivers", "-opt-in=androidx.compose.foundation.layout.ExperimentalLayoutApi", "-opt-in=androidx.compose.material.ExperimentalMaterialApi", diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 0ce5d68de..b72b8a98b 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -3,14 +3,16 @@ plugins { } dependencies { + implementation(androidx.gradle) + implementation(kotlinx.gradle) + implementation(kotlinx.compose.compiler.gradle) + implementation(libs.detekt.gradlePlugin) + implementation(gradleApi()) + implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) implementation(files(androidx.javaClass.superclass.protectionDomain.codeSource.location)) implementation(files(compose.javaClass.superclass.protectionDomain.codeSource.location)) implementation(files(kotlinx.javaClass.superclass.protectionDomain.codeSource.location)) - implementation(androidx.gradle) - implementation(kotlinx.gradle) - implementation(libs.detekt.gradlePlugin) - implementation(gradleApi()) } repositories { diff --git a/buildSrc/src/main/kotlin/mihon.android.application.compose.gradle.kts b/buildSrc/src/main/kotlin/mihon.android.application.compose.gradle.kts index eda5fb22e..6b330b1d9 100644 --- a/buildSrc/src/main/kotlin/mihon.android.application.compose.gradle.kts +++ b/buildSrc/src/main/kotlin/mihon.android.application.compose.gradle.kts @@ -1,4 +1,3 @@ -import mihon.buildlogic.AndroidConfig import mihon.buildlogic.configureCompose plugins { diff --git a/buildSrc/src/main/kotlin/mihon/buildlogic/AndroidConfig.kt b/buildSrc/src/main/kotlin/mihon/buildlogic/AndroidConfig.kt index afea120de..23f0d2b9a 100644 --- a/buildSrc/src/main/kotlin/mihon/buildlogic/AndroidConfig.kt +++ b/buildSrc/src/main/kotlin/mihon/buildlogic/AndroidConfig.kt @@ -1,11 +1,15 @@ package mihon.buildlogic import org.gradle.api.JavaVersion as GradleJavaVersion +import org.jetbrains.kotlin.gradle.dsl.JvmTarget as KotlinJvmTarget object AndroidConfig { const val COMPILE_SDK = 34 const val TARGET_SDK = 34 const val MIN_SDK = 26 const val NDK = "26.1.10909125" + + // https://youtrack.jetbrains.com/issue/KT-66995/JvmTarget-and-JavaVersion-compatibility-for-easier-JVM-version-setup val JavaVersion = GradleJavaVersion.VERSION_17 + val JvmTarget = KotlinJvmTarget.JVM_17 } diff --git a/buildSrc/src/main/kotlin/mihon/buildlogic/ProjectExtensions.kt b/buildSrc/src/main/kotlin/mihon/buildlogic/ProjectExtensions.kt index 874e556a2..4b9e762b9 100644 --- a/buildSrc/src/main/kotlin/mihon/buildlogic/ProjectExtensions.kt +++ b/buildSrc/src/main/kotlin/mihon/buildlogic/ProjectExtensions.kt @@ -8,9 +8,12 @@ import org.gradle.accessors.dm.LibrariesForLibs import org.gradle.api.Project import org.gradle.api.tasks.testing.Test import org.gradle.api.tasks.testing.logging.TestLogEvent +import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.provideDelegate import org.gradle.kotlin.dsl.the import org.gradle.kotlin.dsl.withType +import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension import org.jetbrains.kotlin.gradle.tasks.KotlinCompile val Project.androidx get() = the() @@ -37,15 +40,18 @@ internal fun Project.configureAndroid(commonExtension: CommonExtension<*, *, *, } tasks.withType().configureEach { - kotlinOptions { - jvmTarget = AndroidConfig.JavaVersion.toString() - // freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn" - // freeCompilerArgs += "-Xcontext-receivers" + compilerOptions { + jvmTarget.set(AndroidConfig.JvmTarget) + freeCompilerArgs.addAll( + "-opt-in=kotlin.RequiresOptIn", + "-Xcontext-receivers", + ) // Treat all Kotlin warnings as errors (disabled by default) // Override by setting warningsAsErrors=true in your ~/.gradle/gradle.properties - // val warningsAsErrors: String? by project - // allWarningsAsErrors = warningsAsErrors.toBoolean() + val warningsAsErrors: String? by project + allWarningsAsErrors.set(warningsAsErrors.toBoolean()) + } } @@ -55,51 +61,41 @@ internal fun Project.configureAndroid(commonExtension: CommonExtension<*, *, *, } internal fun Project.configureCompose(commonExtension: CommonExtension<*, *, *, *, *, *>) { + pluginManager.apply(kotlinx.plugins.compose.compiler.get().pluginId) + commonExtension.apply { buildFeatures { compose = true } - composeOptions { - kotlinCompilerExtensionVersion = compose.versions.compiler.get() - } - dependencies { "implementation"(platform(compose.bom)) } } - tasks.withType().configureEach { - kotlinOptions { - freeCompilerArgs += buildComposeMetricsParameters() + extensions.configure { + // Enable strong skipping mode + enableStrongSkippingMode.set(true) - // Enable experimental compiler opts - // https://developer.android.com/jetpack/androidx/releases/compose-compiler#1.5.9 - freeCompilerArgs += listOf( - "-P", - "plugin:androidx.compose.compiler.plugins.kotlin:nonSkippingGroupOptimization=true", - ) + // Enable experimental compiler opts + // https://developer.android.com/jetpack/androidx/releases/compose-compiler#1.5.9 + enableNonSkippingGroupOptimization.set(true) + + val enableMetrics = project.providers.gradleProperty("enableComposeCompilerMetrics").orNull.toBoolean() + val enableReports = project.providers.gradleProperty("enableComposeCompilerReports").orNull.toBoolean() + + val rootProjectDir = rootProject.layout.buildDirectory.asFile.get() + val relativePath = projectDir.relativeTo(rootDir) + if (enableMetrics) { + val buildDirPath = rootProjectDir.resolve("compose-metrics").resolve(relativePath) + metricsDestination.set(buildDirPath) + } + if (enableReports) { + val buildDirPath = rootProjectDir.resolve("compose-reports").resolve(relativePath) + reportsDestination.set(buildDirPath) } } -} -private fun Project.buildComposeMetricsParameters(): List { - val rootProjectDir = rootProject.layout.buildDirectory.asFile.get() - val relativePath = projectDir.relativeTo(rootDir) - - val enableMetrics = project.providers.gradleProperty("enableComposeCompilerMetrics").orNull.toBoolean() - val enableReports = project.providers.gradleProperty("enableComposeCompilerReports").orNull.toBoolean() - - return listOfNotNull( - ("metricsDestination" to "compose-metrics").takeIf { enableMetrics }, - ("reportsDestination" to "compose-reports").takeIf { enableReports }, - ).flatMap { (flag, dirName) -> - val buildDirPath = rootProjectDir.resolve(dirName).resolve(relativePath).absolutePath - listOf( - "-P", - "plugin:androidx.compose.compiler.plugins.kotlin:$flag=$buildDirPath" - ) - } } internal fun Project.configureTest() { diff --git a/data/build.gradle.kts b/data/build.gradle.kts index e3f9d9004..2fded2043 100644 --- a/data/build.gradle.kts +++ b/data/build.gradle.kts @@ -33,7 +33,7 @@ dependencies { tasks { withType { - kotlinOptions.freeCompilerArgs += listOf( + compilerOptions.freeCompilerArgs.addAll( "-Xcontext-receivers", "-opt-in=kotlinx.serialization.ExperimentalSerializationApi", ) diff --git a/domain/build.gradle.kts b/domain/build.gradle.kts index c49c5bc51..5e2357181 100644 --- a/domain/build.gradle.kts +++ b/domain/build.gradle.kts @@ -31,7 +31,7 @@ dependencies { tasks { withType { - kotlinOptions.freeCompilerArgs += listOf( + compilerOptions.freeCompilerArgs.addAll( "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", "-Xcontext-receivers", ) diff --git a/gradle/compose.versions.toml b/gradle/compose.versions.toml index 3f1d253e1..ea04b45ff 100644 --- a/gradle/compose.versions.toml +++ b/gradle/compose.versions.toml @@ -1,11 +1,8 @@ [versions] -compiler = "1.5.14" compose-bom = "2024.05.00-alpha02" accompanist = "0.35.0-alpha" [libraries] -compiler = { module = "androidx.compose.compiler:compiler", version.ref = "compiler" } - activity = "androidx.activity:activity-compose:1.9.0" bom = { group = "dev.chrisbanes.compose", name = "compose-bom", version.ref = "compose-bom" } foundation = { module = "androidx.compose.foundation:foundation" } diff --git a/gradle/kotlinx.versions.toml b/gradle/kotlinx.versions.toml index 66e69752a..6cfb1bdd9 100644 --- a/gradle/kotlinx.versions.toml +++ b/gradle/kotlinx.versions.toml @@ -1,11 +1,12 @@ [versions] -kotlin_version = "1.9.24" +kotlin_version = "2.0.0" serialization_version = "1.6.3" xml_serialization_version = "0.86.3" [libraries] reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin_version" } gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin_version" } +compose-compiler-gradle = { module = "org.jetbrains.kotlin:compose-compiler-gradle-plugin", version.ref = "kotlin_version" } immutables = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version = "0.3.7" } @@ -28,4 +29,5 @@ serialization = ["serialization-json", "serialization-json-okio", "serialization [plugins] android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin_version" } +compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin_version" } serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin_version" } \ No newline at end of file diff --git a/i18n/build.gradle.kts b/i18n/build.gradle.kts index c782eac0f..bdfe09b97 100644 --- a/i18n/build.gradle.kts +++ b/i18n/build.gradle.kts @@ -50,7 +50,7 @@ tasks { } withType { - kotlinOptions.freeCompilerArgs += listOf( + compilerOptions.freeCompilerArgs.addAll( "-Xexpect-actual-classes", ) } diff --git a/presentation-core/build.gradle.kts b/presentation-core/build.gradle.kts index 8fca92019..c6e5c0b65 100644 --- a/presentation-core/build.gradle.kts +++ b/presentation-core/build.gradle.kts @@ -34,7 +34,7 @@ dependencies { tasks { // See https://kotlinlang.org/docs/reference/experimental.html#experimental-status-of-experimental-api(-markers) withType { - kotlinOptions.freeCompilerArgs += listOf( + compilerOptions.freeCompilerArgs.addAll( "-opt-in=androidx.compose.foundation.layout.ExperimentalLayoutApi", "-opt-in=androidx.compose.material.ExperimentalMaterialApi", "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api", diff --git a/source-api/build.gradle.kts b/source-api/build.gradle.kts index ae28caa14..7ac4d6e2c 100644 --- a/source-api/build.gradle.kts +++ b/source-api/build.gradle.kts @@ -38,7 +38,7 @@ android { tasks { withType { - kotlinOptions.freeCompilerArgs += listOf( + compilerOptions.freeCompilerArgs.addAll( "-Xexpect-actual-classes", ) } diff --git a/source-local/build.gradle.kts b/source-local/build.gradle.kts index b63ae8fab..b0a720b97 100644 --- a/source-local/build.gradle.kts +++ b/source-local/build.gradle.kts @@ -40,7 +40,7 @@ android { tasks { withType { - kotlinOptions.freeCompilerArgs += listOf( + compilerOptions.freeCompilerArgs.addAll( "-Xexpect-actual-classes", "-opt-in=kotlinx.serialization.ExperimentalSerializationApi", ) diff --git a/source-local/src/androidMain/kotlin/tachiyomi/source/local/LocalSource.kt b/source-local/src/androidMain/kotlin/tachiyomi/source/local/LocalSource.kt index 06ed4551d..8efea5fd2 100644 --- a/source-local/src/androidMain/kotlin/tachiyomi/source/local/LocalSource.kt +++ b/source-local/src/androidMain/kotlin/tachiyomi/source/local/LocalSource.kt @@ -7,6 +7,7 @@ import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.UnmeteredSource import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.MangasPage +import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder @@ -20,17 +21,17 @@ import mihon.core.common.extensions.toZipFile import nl.adaptivity.xmlutil.AndroidXmlReader import nl.adaptivity.xmlutil.serialization.XML import tachiyomi.core.common.i18n.stringResource -import tachiyomi.core.metadata.comicinfo.COMIC_INFO_FILE -import tachiyomi.core.metadata.comicinfo.ComicInfo -import tachiyomi.core.metadata.comicinfo.copyFromComicInfo -import tachiyomi.core.metadata.comicinfo.getComicInfo -import tachiyomi.core.metadata.tachiyomi.MangaDetails import tachiyomi.core.common.storage.extension import tachiyomi.core.common.storage.nameWithoutExtension import tachiyomi.core.common.storage.openReadOnlyChannel import tachiyomi.core.common.util.lang.withIOContext import tachiyomi.core.common.util.system.ImageUtil import tachiyomi.core.common.util.system.logcat +import tachiyomi.core.metadata.comicinfo.COMIC_INFO_FILE +import tachiyomi.core.metadata.comicinfo.ComicInfo +import tachiyomi.core.metadata.comicinfo.copyFromComicInfo +import tachiyomi.core.metadata.comicinfo.getComicInfo +import tachiyomi.core.metadata.tachiyomi.MangaDetails import tachiyomi.domain.chapter.service.ChapterRecognition import tachiyomi.domain.manga.model.Manga import tachiyomi.i18n.MR @@ -294,7 +295,7 @@ actual class LocalSource( override fun getFilterList() = FilterList(OrderBy.Popular(context)) // Unused stuff - override suspend fun getPageList(chapter: SChapter) = throw UnsupportedOperationException("Unused") + override suspend fun getPageList(chapter: SChapter): List = throw UnsupportedOperationException("Unused") fun getFormat(chapter: SChapter): Format { try {