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>
(cherry picked from commit 46003ec25139319079abc9fde89b3afd344a1a11)

# Conflicts:
#	.github/renovate.json5
#	gradle/compose.versions.toml
#	source-local/src/androidMain/kotlin/tachiyomi/source/local/LocalSource.kt
This commit is contained in:
renovate[bot] 2024-06-07 03:48:35 +06:00 committed by Jobobby04
parent 0121fe9397
commit 6a1ff99441
16 changed files with 57 additions and 55 deletions

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

@ -302,7 +302,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 = 23 const val MIN_SDK = 23
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",
)
}
}
}
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 enableMetrics = project.providers.gradleProperty("enableComposeCompilerMetrics").orNull.toBoolean()
val enableReports = project.providers.gradleProperty("enableComposeCompilerReports").orNull.toBoolean() val enableReports = project.providers.gradleProperty("enableComposeCompilerReports").orNull.toBoolean()
return listOfNotNull( val rootProjectDir = rootProject.layout.buildDirectory.asFile.get()
("metricsDestination" to "compose-metrics").takeIf { enableMetrics }, val relativePath = projectDir.relativeTo(rootDir)
("reportsDestination" to "compose-reports").takeIf { enableReports }, if (enableMetrics) {
).flatMap { (flag, dirName) -> val buildDirPath = rootProjectDir.resolve("compose-metrics").resolve(relativePath)
val buildDirPath = rootProjectDir.resolve(dirName).resolve(relativePath).absolutePath metricsDestination.set(buildDirPath)
listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:$flag=$buildDirPath"
)
} }
if (enableReports) {
val buildDirPath = rootProjectDir.resolve("compose-reports").resolve(relativePath)
reportsDestination.set(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

@ -35,7 +35,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,12 +1,9 @@
[versions] [versions]
compiler = "1.5.14"
# 2024.04.00-alpha01 has several bugs with the new animateItem() modifier # 2024.04.00-alpha01 has several bugs with the new animateItem() modifier
compose-bom = "2024.03.00-alpha02" compose-bom = "2024.03.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

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

View File

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

View File

@ -37,7 +37,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

@ -44,7 +44,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

@ -46,7 +46,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

@ -8,6 +8,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
@ -384,7 +385,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 {