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

[WIP] Update to Kotlin 2.0 #868

Draft
wants to merge 13 commits into
base: dev
Choose a base branch
from
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# 1.7.0

- [Refactor] Update to Kotlin 2.0
- [KMP] Migration core:activityholder, core:di, core:progpress, core:ui:decompose
- [Feature] Add new FlipperPallet
- [Feature] Add changelog screen
Expand Down
1 change: 1 addition & 0 deletions build-logic/plugins/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies {
implementation(libs.square.anvil.gradle)
implementation(libs.ktorfit.gradle)
implementation(libs.compose.multiplatform.gradle)
implementation(libs.compose.gradle)
implementation(libs.kotlin.jvm.gradle)

implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ class FlipperMultiplatformDependenciesPlugin : Plugin<Project> {
} else {
fullSourceSetName
}

target.extensions.create(
"${noMainSourceSetName}Dependencies",
FlipperMultiplatformDependenciesScope::class,
target,
fullSourceSetName
)
sourceSet.dependencies {
target.extensions.create(
"${noMainSourceSetName}Dependencies",
FlipperMultiplatformDependenciesScope::class,
this
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
package com.flipperdevices.buildlogic.plugin

import com.flipperdevices.buildlogic.util.ProjectExt.kotlin
import org.gradle.api.Project
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
import org.jetbrains.kotlin.gradle.plugin.mpp.DefaultKotlinDependencyHandler

open class FlipperMultiplatformDependenciesScope(
project: Project,
name: String
) : KotlinDependencyHandler by DefaultKotlinDependencyHandler(
parent = project.kotlin.sourceSets.getByName(name),
project = project
)
handler: KotlinDependencyHandler
) : KotlinDependencyHandler by handler
31 changes: 16 additions & 15 deletions build-logic/plugins/convention/src/main/kotlin/commonAndroid.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.kotlin.dsl.add
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

private const val SPLASH_SCREEN_ACTIVITY = "com.flipperdevices.singleactivity.impl.SingleActivity"
Expand Down Expand Up @@ -101,21 +102,21 @@ private fun BaseExtension.configureCompileOptions() {
private fun Project.suppressOptIn() {
tasks.withType<KotlinCompile>()
.configureEach {
kotlinOptions {
jvmTarget = "11"

freeCompilerArgs = freeCompilerArgs + listOf(
"-Xopt-in=com.google.accompanist.pager.ExperimentalPagerApi",
"-Xopt-in=androidx.compose.ui.ExperimentalComposeUiApi",
"-Xopt-in=androidx.compose.foundation.ExperimentalFoundationApi",
"-Xopt-in=kotlinx.serialization.ExperimentalSerializationApi",
"-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-Xopt-in=com.squareup.anvil.annotations.ExperimentalAnvilApi",
"-Xopt-in=kotlin.time.ExperimentalTime",
"-Xopt-in=kotlin.RequiresOptIn",
"-Xopt-in=androidx.compose.animation.ExperimentalAnimationApi",
"-Xopt-in=com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi", // ktlint-disable max-line-length
"-Xopt-in=androidx.compose.foundation.layout.ExperimentalLayoutApi"
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)

optIn.addAll(
"com.google.accompanist.pager.ExperimentalPagerApi",
"androidx.compose.ui.ExperimentalComposeUiApi",
"androidx.compose.foundation.ExperimentalFoundationApi",
"kotlinx.serialization.ExperimentalSerializationApi",
"kotlinx.coroutines.ExperimentalCoroutinesApi",
"com.squareup.anvil.annotations.ExperimentalAnvilApi",
"kotlin.time.ExperimentalTime",
"kotlin.RequiresOptIn",
"androidx.compose.animation.ExperimentalAnimationApi",
"com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi", // ktlint-disable max-line-length
"androidx.compose.foundation.layout.ExperimentalLayoutApi"
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plugins {
id("com.android.application")
id("kotlin-android")
id("io.sentry.android.gradle")
id("org.jetbrains.kotlin.plugin.compose")
}

@Suppress("UnstableApiUsage")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ import com.android.build.gradle.BaseExtension

plugins {
id("flipper.android-lib")
id("org.jetbrains.kotlin.plugin.compose")
}

@Suppress("UnstableApiUsage")
configure<BaseExtension> {
buildFeatures.compose = true

composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ plugins {
}

anvil {
generateDaggerFactories.set(true)
useKsp(contributesAndFactoryGeneration = true)
generateDaggerFactories = true
}

pluginManager.withPlugin("kotlin-kapt") {
anvil {
generateDaggerFactories.set(false)
}
error("Please, use `id(\"flipper.anvil.kapt\")` instead")
}

dependencies {
"implementation"(libs.dagger)
"implementation"(libs.anvil.utils.annotations)
"anvil"(libs.anvil.utils.compiler)
"ksp"(libs.anvil.utils.compiler)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.internal.KaptGenerateStubsTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("com.squareup.anvil")
}

tasks.withType<KaptGenerateStubsTask>().configureEach {
// TODO necessary until anvil supports something for K2 contribution merging
compilerOptions {
progressiveMode.set(false)
languageVersion.set(KotlinVersion.KOTLIN_1_9)
}
}

tasks.withType<KotlinCompile>().configureEach {
// TODO necessary until anvil supports something for K2 contribution merging
compilerOptions {
progressiveMode.set(false)
languageVersion.set(KotlinVersion.KOTLIN_1_9)
}
}

dependencies {
"implementation"(libs.dagger)
"implementation"(libs.anvil.utils.annotations)
"anvil"(libs.anvil.utils.compiler)
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import com.android.build.gradle.BaseExtension
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id("org.jetbrains.kotlin.multiplatform")
id("org.jetbrains.compose")
id("org.jetbrains.kotlin.plugin.compose")
id("com.android.library")
}

Expand All @@ -12,10 +14,8 @@ configure<BaseExtension> {

kotlin {
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
compilerOptions {
jvmTarget = JvmTarget.JVM_1_8
}
}
jvm("desktop")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.android.build.gradle.BaseExtension
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id("org.jetbrains.kotlin.multiplatform")
Expand All @@ -11,10 +12,8 @@ configure<BaseExtension> {

kotlin {
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
compilerOptions {
jvmTarget = JvmTarget.JVM_1_8
}
}
jvm("desktop")
Expand Down
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ plugins {
alias(libs.plugins.square.anvil) apply false
alias(libs.plugins.protobuf) apply false
alias(libs.plugins.google.gms) apply false
id("flipper.lint")
alias(libs.plugins.android.test) apply false
alias(libs.plugins.baselineprofile) apply false
id("flipper.lint")
alias(libs.plugins.compose) apply false
alias(libs.plugins.buildkonfig) apply false
}
5 changes: 1 addition & 4 deletions components/bridge/connection/sample/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("flipper.android-app")
id("flipper.anvil")
id("flipper.anvil.kapt")
id("kotlin-kapt")
id("kotlinx-serialization")
}
Expand All @@ -9,9 +9,6 @@ android.namespace = "com.flipperdevices.bridge.connection"

android {
buildFeatures.compose = true
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
}

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fun AppCard(
private fun AppCardTop(
fapItem: FapItemShort?,
modifier: Modifier = Modifier,
installationButton: @Composable (modifier: Modifier) -> Unit
installationButton: @Composable (Modifier) -> Unit
) {
Row(
modifier = modifier
Expand Down Expand Up @@ -110,7 +110,7 @@ private fun AppCardTop(
)
}
installationButton(
modifier = Modifier
Modifier
.fillMaxHeight()
.padding(vertical = 4.dp)
)
Expand Down
5 changes: 1 addition & 4 deletions components/nfceditor/sample/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
plugins {
id("flipper.android-app")
id("flipper.anvil")
id("flipper.anvil.kapt")
id("kotlin-kapt")
}

android.namespace = "com.flipperdevices.nfceditor.sample"

android {
buildFeatures.compose = true
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
}

android {
Expand Down
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx3g
#org.gradle.debug=true
#kotlin.compiler.execution.strategy=in-process
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
Expand All @@ -30,4 +32,5 @@ org.gradle.daemon=false
kotlin.incremental.useClasspathSnapshot=false
kotlin.incremental=false
# https://developer.android.com/build/releases/gradle-plugin
android.suppressUnsupportedCompileSdk=34
android.suppressUnsupportedCompileSdk=34
kotlin.mpp.androidGradlePluginCompatibility.nowarn=true
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
[versions]
# You also need to bump the version of ksp, anvil, compose
kotlin-general = "1.9.24" # https://kotlinlang.org/docs/releases.html#release-details
kotlin-general = "2.0.0" # https://kotlinlang.org/docs/releases.html#release-details
kotlin-immutable-collections = "0.3.7" # https://github.com/Kotlin/kotlinx.collections.immutable/releases
kotlin-datetime = "0.6.0" # https://github.com/Kotlin/kotlinx-datetime/releases
kotlinx = "1.8.1" # https://github.com/Kotlin/kotlinx.coroutines/releases
ksp = "1.9.24-1.0.20" # https://github.com/google/ksp/releases
anvil = "2.4.9" # https://github.com/square/anvil/releases
anvil-utils = "0.1.0" # https://github.com/IlyaGulya/anvil-utils/releases
ksp = "2.0.0-1.0.21" # https://github.com/google/ksp/releases
anvil = "2.5.0-beta09" # https://github.com/square/anvil/releases
anvil-utils = "0.2.0-beta01" # https://github.com/IlyaGulya/anvil-utils/releases
android-gradle = "8.4.1" # https://developer.android.com/studio/releases/gradle-plugin
protobuf = "4.26.1" # https://github.com/protocolbuffers/protobuf/releases
protobuf-gradle = "0.9.4" # https://github.com/google/protobuf-gradle-plugin/releases
compose-material = "1.6.7" # https://developer.android.com/jetpack/androidx/releases/compose#versions
compose-foundation = "1.6.7" # https://developer.android.com/jetpack/androidx/releases/compose#versions
compose-ui = "1.6.7" # https://developer.android.com/jetpack/androidx/releases/compose#versions
compose-wear = "1.3.1" # https://developer.android.com/jetpack/androidx/releases/wear-compose
compose-compiler = "1.5.14" # https://developer.android.com/jetpack/androidx/releases/compose#versions
compose-accompanist = "0.34.0" # https://github.com/google/accompanist/releases
compose-constraint = "1.0.1" # https://developer.android.com/jetpack/compose/layouts/constraintlayout
compose-paging = "3.3.0" # https://developer.android.com/jetpack/androidx/releases/paging
Expand Down Expand Up @@ -148,10 +147,10 @@ compose-swipetorefresh = { module = "com.google.accompanist:accompanist-swiperef
compose-constraint = { module = "androidx.constraintlayout:constraintlayout-compose", version.ref = "compose-constraint" }
compose-paging = { module = "androidx.paging:paging-compose", version.ref = "compose-paging" }
compose-drag-drop = { module = "org.burnoutcrew.composereorderable:reorderable", version.ref = "compose-drag-drop" }
compose-compiler = { module = "androidx.compose.compiler:compiler", version.ref = "compose-compiler" } # Need for renovate

# UI - Compose multiplatform
compose-multiplatform-gradle = { module = "org.jetbrains.compose:compose-gradle-plugin", version.ref = "compose-multiplatform" }
compose-gradle = { module = "org.jetbrains.kotlin:compose-compiler-gradle-plugin", version.ref = "kotlin-general" }


# Coil
Expand Down Expand Up @@ -290,4 +289,5 @@ protobuf = { id = "com.google.protobuf", version.ref = "protobuf-gradle" }
square-anvil = { id = "com.squareup.anvil", version.ref = "anvil" }
google-gms = { id = "com.google.gms.google-services", version.ref = "google-gms-gradle" }
baselineprofile = { id = "androidx.baselineprofile", version.ref = "baselineprofile" }
compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin-general" }
buildkonfig = { id = "com.github.gmazzo.buildconfig", version.ref = "buildkonfig" }
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-rc-1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Loading
Loading