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

Update to Kotlin 2.0 #868

Merged
merged 20 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# 1.7.2 - In Progress

- [Refactor] Update to Kotlin 2.0
- [FIX] Distinct fap items by id in paging sources
- [FIX] Battery level charge
- [FIX] Button arrow tint
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(
"-opt-in=com.google.accompanist.pager.ExperimentalPagerApi",
"-opt-in=androidx.compose.ui.ExperimentalComposeUiApi",
"-opt-in=androidx.compose.foundation.ExperimentalFoundationApi",
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-opt-in=com.squareup.anvil.annotations.ExperimentalAnvilApi",
"-opt-in=kotlin.time.ExperimentalTime",
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=androidx.compose.animation.ExperimentalAnimationApi",
"-opt-in=com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi", // ktlint-disable max-line-length
"-opt-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 @@ -9,6 +9,7 @@ plugins {
id("kotlin-android")
id("io.sentry.android.gradle")
id("flipper.lint")
id("org.jetbrains.kotlin.plugin.compose")
}

@Suppress("UnstableApiUsage")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
import com.android.build.gradle.BaseExtension

plugins {
id("flipper.android-lib")
}

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

composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
id("org.jetbrains.kotlin.plugin.compose")
}
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")
id("flipper.lint")
}
Expand All @@ -13,10 +15,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 @@ -12,10 +13,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
9 changes: 1 addition & 8 deletions components/nfceditor/sample/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
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 {
defaultConfig {
applicationId = "com.flipperdevices.nfceditor.sample"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.flipperdevices.remotecontrols.impl.brands.presentation.decompose
import com.arkivanov.decompose.ComponentContext
import com.flipperdevices.ifrmvp.backend.model.BrandModel
import com.flipperdevices.remotecontrols.impl.brands.presentation.util.charSection
import com.flipperdevices.ui.decompose.DecomposeOnBackParameter
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import kotlinx.collections.immutable.toImmutableSet
Expand Down Expand Up @@ -49,7 +50,7 @@ interface BrandsDecomposeComponent {
fun createBrandsComponent(
componentContext: ComponentContext,
categoryId: Long,
onBackClicked: () -> Unit,
onBackClicked: DecomposeOnBackParameter,
onBrandClicked: (brandId: Long) -> Unit
): BrandsDecomposeComponent
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.flipperdevices.ifrmvp.backend.model.BrandModel
import com.flipperdevices.remotecontrols.impl.brands.presentation.decompose.BrandsDecomposeComponent
import com.flipperdevices.remotecontrols.impl.brands.presentation.viewmodel.BrandsListViewModel
import com.flipperdevices.remotecontrols.impl.brands.presentation.viewmodel.QueryViewModel
import com.flipperdevices.ui.decompose.DecomposeOnBackParameter
import dagger.assisted.Assisted
import dagger.assisted.AssistedInject
import kotlinx.collections.immutable.toImmutableList
Expand All @@ -23,7 +24,7 @@ import javax.inject.Provider
@ContributesAssistedFactory(AppGraph::class, BrandsDecomposeComponent.Factory::class)
class BrandsDecomposeComponentImpl @AssistedInject constructor(
@Assisted componentContext: ComponentContext,
@Assisted private val onBackClicked: () -> Unit,
@Assisted private val onBackClicked: DecomposeOnBackParameter,
@Assisted private val onBrandClicked: (brandId: Long) -> Unit,
@Assisted categoryId: Long,
createBrandsListViewModel: BrandsListViewModel.Factory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.flipperdevices.remotecontrols.impl.categories.presentation.decompose

import com.arkivanov.decompose.ComponentContext
import com.flipperdevices.ifrmvp.backend.model.DeviceCategory
import com.flipperdevices.ui.decompose.DecomposeOnBackParameter
import kotlinx.collections.immutable.ImmutableList
import kotlinx.coroutines.flow.StateFlow

Expand All @@ -23,7 +24,7 @@ interface DeviceCategoriesComponent {
fun interface Factory {
fun invoke(
componentContext: ComponentContext,
onBackClicked: () -> Unit,
onBackClicked: DecomposeOnBackParameter,
onCategoryClicked: (categoryId: Long) -> Unit
): DeviceCategoriesComponent
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.flipperdevices.core.di.AppGraph
import com.flipperdevices.ifrmvp.backend.model.DeviceCategory
import com.flipperdevices.remotecontrols.impl.categories.presentation.decompose.DeviceCategoriesComponent
import com.flipperdevices.remotecontrols.impl.categories.presentation.viewmodel.DeviceCategoryListViewModel
import com.flipperdevices.ui.decompose.DecomposeOnBackParameter
import dagger.assisted.Assisted
import dagger.assisted.AssistedInject
import me.gulya.anvil.assisted.ContributesAssistedFactory
Expand All @@ -14,7 +15,7 @@ import javax.inject.Provider
@ContributesAssistedFactory(AppGraph::class, DeviceCategoriesComponent.Factory::class)
class DeviceCategoriesComponentImpl @AssistedInject constructor(
@Assisted componentContext: ComponentContext,
@Assisted private val onBackClicked: () -> Unit,
@Assisted private val onBackClicked: DecomposeOnBackParameter,
@Assisted private val onCategoryClicked: (categoryId: Long) -> Unit,
createDeviceCategoryListViewModel: Provider<DeviceCategoryListViewModel>,
) : DeviceCategoriesComponent,
Expand All @@ -26,7 +27,7 @@ class DeviceCategoriesComponentImpl @AssistedInject constructor(
override val model = deviceCategoryListFeature.model

override fun onCategoryClicked(category: DeviceCategory) {
onCategoryClicked.invoke(category.id)
onCategoryClicked(category.id)
}

override fun onBackClicked() = onBackClicked.invoke()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.arkivanov.decompose.ComponentContext
import com.flipperdevices.ifrmvp.backend.model.IfrFileModel
import com.flipperdevices.ifrmvp.backend.model.SignalResponseModel
import com.flipperdevices.remotecontrols.api.SetupScreenDecomposeComponent
import com.flipperdevices.ui.decompose.DecomposeOnBackParameter
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
Expand Down Expand Up @@ -42,7 +43,7 @@ interface SetupComponent {
fun createSetupComponent(
componentContext: ComponentContext,
param: SetupScreenDecomposeComponent.Param,
onBack: () -> Unit,
onBack: DecomposeOnBackParameter,
onIfrFileFound: (ifrFileId: Long) -> Unit
): SetupComponent
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.flipperdevices.remotecontrols.impl.setup.presentation.decompose.Setup
import com.flipperdevices.remotecontrols.impl.setup.presentation.decompose.internal.mapping.toFFFormat
import com.flipperdevices.remotecontrols.impl.setup.presentation.viewmodel.CurrentSignalViewModel
import com.flipperdevices.remotecontrols.impl.setup.presentation.viewmodel.HistoryViewModel
import com.flipperdevices.ui.decompose.DecomposeOnBackParameter
import dagger.assisted.Assisted
import dagger.assisted.AssistedInject
import kotlinx.coroutines.CoroutineScope
Expand All @@ -33,7 +34,7 @@ import javax.inject.Provider
class SetupComponentImpl @AssistedInject constructor(
@Assisted componentContext: ComponentContext,
@Assisted override val param: SetupScreenDecomposeComponent.Param,
@Assisted private val onBackClicked: () -> Unit,
@Assisted private val onBackClicked: DecomposeOnBackParameter,
@Assisted private val onIfrFileFound: (ifrFileId: Long) -> Unit,
currentSignalViewModelFactory: CurrentSignalViewModel.Factory,
createHistoryViewModel: Provider<HistoryViewModel>,
Expand Down
Loading
Loading