fix(deps): update kotlin and compose to v2 (major) (#3064)

* fix(deps): update kotlin and compose to v2

* fix(build): switch to Kotlin Compose Compiler

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
renovate[bot] 2024-05-22 07:12:27 +00:00 committed by GitHub
parent dd4a7023cd
commit 8bae8dfe25
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 9 additions and 39 deletions

3
.gitignore vendored
View file

@ -160,3 +160,6 @@ fabric.properties
# Default output directory for APK and Bundle collection tasks # Default output directory for APK and Bundle collection tasks
app/outputs app/outputs
# K2 generated directory
.kotlin/

View file

@ -13,6 +13,7 @@ plugins {
id("com.github.android-password-store.sentry") id("com.github.android-password-store.sentry")
id("com.github.android-password-store.rename-artifacts") id("com.github.android-password-store.rename-artifacts")
alias(libs.plugins.hilt) alias(libs.plugins.hilt)
alias(libs.plugins.kotlin.composeCompiler)
} }
crowdin { crowdin {
@ -30,10 +31,7 @@ android {
} }
buildFeatures { compose = true } buildFeatures { compose = true }
composeOptions { composeOptions { useLiveLiterals = false }
useLiveLiterals = false
kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
}
packaging { resources.excludes.add("META-INF/versions/**") } packaging { resources.excludes.add("META-INF/versions/**") }
} }

View file

@ -6,15 +6,12 @@
package app.passwordstore.gradle package app.passwordstore.gradle
import app.passwordstore.gradle.KotlinCommonPlugin.Companion.JVM_TOOLCHAIN_ACTION import app.passwordstore.gradle.KotlinCommonPlugin.Companion.JVM_TOOLCHAIN_ACTION
import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.Plugin import org.gradle.api.Plugin
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.getByType import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
@Suppress("Unused") @Suppress("Unused")
class KotlinAndroidPlugin : Plugin<Project> { class KotlinAndroidPlugin : Plugin<Project> {
@ -25,30 +22,5 @@ class KotlinAndroidPlugin : Plugin<Project> {
apply(KotlinCommonPlugin::class) apply(KotlinCommonPlugin::class)
} }
project.extensions.getByType<KotlinProjectExtension>().jvmToolchain(JVM_TOOLCHAIN_ACTION) project.extensions.getByType<KotlinProjectExtension>().jvmToolchain(JVM_TOOLCHAIN_ACTION)
val libs = project.extensions.getByName("libs") as LibrariesForLibs
val composeCompilerVersion = libs.versions.composeCompiler.get()
val kotlinVersion = libs.versions.kotlin.get()
val matches = COMPOSE_COMPILER_VERSION_REGEX.find(composeCompilerVersion)
project.tasks.withType<KotlinCompile>().configureEach {
compilerOptions.freeCompilerArgs.addAll(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:featureFlag=StrongSkipping",
)
if (matches != null) {
val (compilerKotlinVersion) = matches.destructured
if (compilerKotlinVersion != kotlinVersion) {
compilerOptions.freeCompilerArgs.addAll(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=$kotlinVersion",
)
}
}
}
}
private companion object {
// Matches against 1.5.0-dev-k1.9.0-6a60475e07f
val COMPOSE_COMPILER_VERSION_REGEX = "\\d.\\d.\\d-dev-k(\\d.\\d.\\d+)-[a-z0-9]+".toRegex()
} }
} }

View file

@ -2,12 +2,10 @@
agp = "8.4.1" agp = "8.4.1"
androidxActivity = "1.9.0" androidxActivity = "1.9.0"
bouncycastle = "1.78.1" bouncycastle = "1.78.1"
# @keep used for kotlinCompilerExtensionVersion
composeCompiler = "1.5.14-dev-k1.9.24-50022def4af"
coroutines = "1.8.1" coroutines = "1.8.1"
flowbinding = "1.2.0" flowbinding = "1.2.0"
hilt = "2.51.1" hilt = "2.51.1"
kotlin = "1.9.24" kotlin = "2.0.0"
kotlinResult = "2.0.0" kotlinResult = "2.0.0"
lifecycle = "2.8.0" lifecycle = "2.8.0"
moshi = "1.15.1" moshi = "1.15.1"
@ -109,3 +107,4 @@ testDependencies = [
[plugins] [plugins]
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" } hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
kotlin-composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }

View file

@ -5,6 +5,7 @@
plugins { plugins {
id("com.github.android-password-store.android-library") id("com.github.android-password-store.android-library")
id("com.github.android-password-store.kotlin-android") id("com.github.android-password-store.kotlin-android")
alias(libs.plugins.kotlin.composeCompiler)
} }
android { android {
@ -12,10 +13,7 @@ android {
compose = true compose = true
androidResources = true androidResources = true
} }
composeOptions { composeOptions { useLiveLiterals = false }
useLiveLiterals = false
kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
}
namespace = "app.passwordstore.ui.compose" namespace = "app.passwordstore.ui.compose"
} }