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>
This commit is contained in:
renovate[bot] 2024-06-07 03:48:35 +06:00 committed by GitHub
parent e8fdfaad64
commit 46003ec251
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 61 additions and 67 deletions

View file

@ -9,14 +9,6 @@
"dev.chrisbanes.compose:compose-bom" "dev.chrisbanes.compose:compose-bom"
], ],
"ignoreUnstable": false "ignoreUnstable": false
},
{
"groupName": "Kotlin and Compose Compiler",
"matchPackagePrefixes": [
"androidx.compose.compiler",
"org.jetbrains.kotlin.",
"org.jetbrains.kotlin:",
],
} }
] ]
} }

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
.gradle .gradle
.kotlin
/local.properties /local.properties
/.idea/workspace.xml /.idea/workspace.xml
.DS_Store .DS_Store

View file

@ -274,7 +274,7 @@ androidComponents {
tasks { tasks {
// See https://kotlinlang.org/docs/reference/experimental.html#experimental-status-of-experimental-api(-markers) // See https://kotlinlang.org/docs/reference/experimental.html#experimental-status-of-experimental-api(-markers)
withType<KotlinCompile> { withType<KotlinCompile> {
kotlinOptions.freeCompilerArgs += listOf( compilerOptions.freeCompilerArgs.addAll(
"-Xcontext-receivers", "-Xcontext-receivers",
"-opt-in=androidx.compose.foundation.layout.ExperimentalLayoutApi", "-opt-in=androidx.compose.foundation.layout.ExperimentalLayoutApi",
"-opt-in=androidx.compose.material.ExperimentalMaterialApi", "-opt-in=androidx.compose.material.ExperimentalMaterialApi",

View file

@ -3,14 +3,16 @@ plugins {
} }
dependencies { 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(libs.javaClass.superclass.protectionDomain.codeSource.location))
implementation(files(androidx.javaClass.superclass.protectionDomain.codeSource.location)) implementation(files(androidx.javaClass.superclass.protectionDomain.codeSource.location))
implementation(files(compose.javaClass.superclass.protectionDomain.codeSource.location)) implementation(files(compose.javaClass.superclass.protectionDomain.codeSource.location))
implementation(files(kotlinx.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 { repositories {

View file

@ -1,4 +1,3 @@
import mihon.buildlogic.AndroidConfig
import mihon.buildlogic.configureCompose import mihon.buildlogic.configureCompose
plugins { plugins {

View file

@ -1,11 +1,15 @@
package mihon.buildlogic package mihon.buildlogic
import org.gradle.api.JavaVersion as GradleJavaVersion import org.gradle.api.JavaVersion as GradleJavaVersion
import org.jetbrains.kotlin.gradle.dsl.JvmTarget as KotlinJvmTarget
object AndroidConfig { object AndroidConfig {
const val COMPILE_SDK = 34 const val COMPILE_SDK = 34
const val TARGET_SDK = 34 const val TARGET_SDK = 34
const val MIN_SDK = 26 const val MIN_SDK = 26
const val NDK = "26.1.10909125" 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 JavaVersion = GradleJavaVersion.VERSION_17
val JvmTarget = KotlinJvmTarget.JVM_17
} }

View file

@ -8,9 +8,12 @@ import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.api.tasks.testing.Test import org.gradle.api.tasks.testing.Test
import org.gradle.api.tasks.testing.logging.TestLogEvent 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.dependencies
import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.the import org.gradle.kotlin.dsl.the
import org.gradle.kotlin.dsl.withType import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
val Project.androidx get() = the<LibrariesForAndroidx>() val Project.androidx get() = the<LibrariesForAndroidx>()
@ -37,15 +40,18 @@ internal fun Project.configureAndroid(commonExtension: CommonExtension<*, *, *,
} }
tasks.withType<KotlinCompile>().configureEach { tasks.withType<KotlinCompile>().configureEach {
kotlinOptions { compilerOptions {
jvmTarget = AndroidConfig.JavaVersion.toString() jvmTarget.set(AndroidConfig.JvmTarget)
// freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn" freeCompilerArgs.addAll(
// freeCompilerArgs += "-Xcontext-receivers" "-opt-in=kotlin.RequiresOptIn",
"-Xcontext-receivers",
)
// Treat all Kotlin warnings as errors (disabled by default) // Treat all Kotlin warnings as errors (disabled by default)
// Override by setting warningsAsErrors=true in your ~/.gradle/gradle.properties // Override by setting warningsAsErrors=true in your ~/.gradle/gradle.properties
// val warningsAsErrors: String? by project val warningsAsErrors: String? by project
// allWarningsAsErrors = warningsAsErrors.toBoolean() allWarningsAsErrors.set(warningsAsErrors.toBoolean())
} }
} }
@ -55,51 +61,41 @@ internal fun Project.configureAndroid(commonExtension: CommonExtension<*, *, *,
} }
internal fun Project.configureCompose(commonExtension: CommonExtension<*, *, *, *, *, *>) { internal fun Project.configureCompose(commonExtension: CommonExtension<*, *, *, *, *, *>) {
pluginManager.apply(kotlinx.plugins.compose.compiler.get().pluginId)
commonExtension.apply { commonExtension.apply {
buildFeatures { buildFeatures {
compose = true compose = true
} }
composeOptions {
kotlinCompilerExtensionVersion = compose.versions.compiler.get()
}
dependencies { dependencies {
"implementation"(platform(compose.bom)) "implementation"(platform(compose.bom))
} }
} }
tasks.withType<KotlinCompile>().configureEach { extensions.configure<ComposeCompilerGradlePluginExtension> {
kotlinOptions { // Enable strong skipping mode
freeCompilerArgs += buildComposeMetricsParameters() enableStrongSkippingMode.set(true)
// Enable experimental compiler opts // Enable experimental compiler opts
// https://developer.android.com/jetpack/androidx/releases/compose-compiler#1.5.9 // https://developer.android.com/jetpack/androidx/releases/compose-compiler#1.5.9
freeCompilerArgs += listOf( enableNonSkippingGroupOptimization.set(true)
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:nonSkippingGroupOptimization=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<String> {
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() { internal fun Project.configureTest() {

View file

@ -33,7 +33,7 @@ dependencies {
tasks { tasks {
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> { withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.freeCompilerArgs += listOf( compilerOptions.freeCompilerArgs.addAll(
"-Xcontext-receivers", "-Xcontext-receivers",
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi", "-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
) )

View file

@ -31,7 +31,7 @@ dependencies {
tasks { tasks {
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> { withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.freeCompilerArgs += listOf( compilerOptions.freeCompilerArgs.addAll(
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-Xcontext-receivers", "-Xcontext-receivers",
) )

View file

@ -1,11 +1,8 @@
[versions] [versions]
compiler = "1.5.14"
compose-bom = "2024.05.00-alpha02" compose-bom = "2024.05.00-alpha02"
accompanist = "0.35.0-alpha" accompanist = "0.35.0-alpha"
[libraries] [libraries]
compiler = { module = "androidx.compose.compiler:compiler", version.ref = "compiler" }
activity = "androidx.activity:activity-compose:1.9.0" activity = "androidx.activity:activity-compose:1.9.0"
bom = { group = "dev.chrisbanes.compose", name = "compose-bom", version.ref = "compose-bom" } bom = { group = "dev.chrisbanes.compose", name = "compose-bom", version.ref = "compose-bom" }
foundation = { module = "androidx.compose.foundation:foundation" } foundation = { module = "androidx.compose.foundation:foundation" }

View file

@ -1,11 +1,12 @@
[versions] [versions]
kotlin_version = "1.9.24" kotlin_version = "2.0.0"
serialization_version = "1.6.3" serialization_version = "1.6.3"
xml_serialization_version = "0.86.3" xml_serialization_version = "0.86.3"
[libraries] [libraries]
reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin_version" } reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin_version" }
gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", 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" } immutables = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version = "0.3.7" }
@ -28,4 +29,5 @@ serialization = ["serialization-json", "serialization-json-okio", "serialization
[plugins] [plugins]
android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin_version" } 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" } serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin_version" }

View file

@ -50,7 +50,7 @@ tasks {
} }
withType<KotlinCompile> { withType<KotlinCompile> {
kotlinOptions.freeCompilerArgs += listOf( compilerOptions.freeCompilerArgs.addAll(
"-Xexpect-actual-classes", "-Xexpect-actual-classes",
) )
} }

View file

@ -34,7 +34,7 @@ dependencies {
tasks { tasks {
// See https://kotlinlang.org/docs/reference/experimental.html#experimental-status-of-experimental-api(-markers) // See https://kotlinlang.org/docs/reference/experimental.html#experimental-status-of-experimental-api(-markers)
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> { withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.freeCompilerArgs += listOf( compilerOptions.freeCompilerArgs.addAll(
"-opt-in=androidx.compose.foundation.layout.ExperimentalLayoutApi", "-opt-in=androidx.compose.foundation.layout.ExperimentalLayoutApi",
"-opt-in=androidx.compose.material.ExperimentalMaterialApi", "-opt-in=androidx.compose.material.ExperimentalMaterialApi",
"-opt-in=androidx.compose.material3.ExperimentalMaterial3Api", "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api",

View file

@ -38,7 +38,7 @@ android {
tasks { tasks {
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> { withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.freeCompilerArgs += listOf( compilerOptions.freeCompilerArgs.addAll(
"-Xexpect-actual-classes", "-Xexpect-actual-classes",
) )
} }

View file

@ -40,7 +40,7 @@ android {
tasks { tasks {
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> { withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.freeCompilerArgs += listOf( compilerOptions.freeCompilerArgs.addAll(
"-Xexpect-actual-classes", "-Xexpect-actual-classes",
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi", "-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
) )

View file

@ -7,6 +7,7 @@ import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.UnmeteredSource import eu.kanade.tachiyomi.source.UnmeteredSource
import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.MangasPage 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.SChapter
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder 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.AndroidXmlReader
import nl.adaptivity.xmlutil.serialization.XML import nl.adaptivity.xmlutil.serialization.XML
import tachiyomi.core.common.i18n.stringResource 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.extension
import tachiyomi.core.common.storage.nameWithoutExtension import tachiyomi.core.common.storage.nameWithoutExtension
import tachiyomi.core.common.storage.openReadOnlyChannel import tachiyomi.core.common.storage.openReadOnlyChannel
import tachiyomi.core.common.util.lang.withIOContext import tachiyomi.core.common.util.lang.withIOContext
import tachiyomi.core.common.util.system.ImageUtil import tachiyomi.core.common.util.system.ImageUtil
import tachiyomi.core.common.util.system.logcat 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.chapter.service.ChapterRecognition
import tachiyomi.domain.manga.model.Manga import tachiyomi.domain.manga.model.Manga
import tachiyomi.i18n.MR import tachiyomi.i18n.MR
@ -294,7 +295,7 @@ actual class LocalSource(
override fun getFilterList() = FilterList(OrderBy.Popular(context)) override fun getFilterList() = FilterList(OrderBy.Popular(context))
// Unused stuff // Unused stuff
override suspend fun getPageList(chapter: SChapter) = throw UnsupportedOperationException("Unused") override suspend fun getPageList(chapter: SChapter): List<Page> = throw UnsupportedOperationException("Unused")
fun getFormat(chapter: SChapter): Format { fun getFormat(chapter: SChapter): Format {
try { try {