Skip to content

Commit

Permalink
Updating the kotlin 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nkuppan committed Jul 29, 2024
1 parent 97afacb commit 0f5c947
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/create_tag.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Create Release Tag
name: Github - Release Tag Create

on:
workflow_call:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish - Play store
name: Play Store - Promote to Production

on:
workflow_call:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish - Play store
name: Play Store - Release to Beta

on:
workflow_call:
Expand Down
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import java.util.Locale
import java.util.Properties

plugins {
id("naveenapps.plugin.android.app")
id("naveenapps.plugin.kotlin.basic")
alias(libs.plugins.naveenapps.android.app)
alias(libs.plugins.naveenapps.kotlin.basic)
id("naveenapps.plugin.compose")
id("naveenapps.plugin.hilt")
id("com.github.triplet.play")
id("com.google.gms.google-services")
id("com.google.firebase.crashlytics")
id("com.google.firebase.appdistribution")
id("com.google.android.gms.oss-licenses-plugin")
id("jacoco")
alias(libs.plugins.compose.compiler)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

val JAVA_VERSION = JavaVersion.VERSION_19
Expand All @@ -18,20 +19,25 @@ fun CommonExtension<*, *, *, *, *, *>.configureJVM() {

fun Project.configureKotlinJVM() {
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = JAVA_VERSION.toString()
compilerOptions {
jvmTarget.set(JvmTarget.JVM_19)

val warningsAsErrors: String? by project
allWarningsAsErrors = warningsAsErrors.toBoolean()
freeCompilerArgs = freeCompilerArgs + listOf(
"-opt-in=kotlin.RequiresOptIn",
// Enable experimental coroutines APIs, including Flow
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-opt-in=kotlinx.coroutines.FlowPreview",
"-opt-in=kotlin.Experimental",
// Enable experimental kotlinx serialization APIs
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
)
allWarningsAsErrors.set(warningsAsErrors.toBoolean())

freeCompilerArgs.also {
it.addAll(
listOf(
"-opt-in=kotlin.RequiresOptIn",
// Enable experimental coroutines APIs, including Flow
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-opt-in=kotlinx.coroutines.FlowPreview",
"-opt-in=kotlin.Experimental",
// Enable experimental kotlinx serialization APIs
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
)
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,16 @@ internal fun Project.configureJacoco() {

sourceDirectories.setFrom(files(sourceDirs))

/*
executionData.setFrom(
files(
listOf("${buildDir}/jacoco/testDebugUnitTest.exec"),
),
)
*/
}

tasks.withType<Test>().configureEach {
configure<JacocoTaskExtension> {
// Required for JaCoCo + Robolectric
// https://github.com/robolectric/robolectric/issues/2230
// TODO: Consider removing if not we don't add Robolectric
isIncludeNoLocationClasses = true

// Required for JDK 11 with the above
// https://github.com/gradle/gradle/issues/5184#issuecomment-391982009
excludes = listOf("jdk.internal.*")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@ import org.gradle.kotlin.dsl.configure
class AndroidComposeConfigPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {

target.pluginManager.apply {
this.apply("org.jetbrains.kotlin.plugin.compose")
}

when {
pluginManager.hasPlugin("com.android.application") ->
pluginManager.hasPlugin("com.android.application") -> {
configure<ApplicationExtension> {
configureAndroidCompose(this)
}
}

pluginManager.hasPlugin("com.android.library") ->
pluginManager.hasPlugin("com.android.library") -> {
configure<com.android.build.api.dsl.LibraryExtension> {
configureAndroidCompose(this)
}
}

else -> Unit
}
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ plugins {
alias(libs.plugins.android.test) apply false
alias(libs.plugins.kotlin) apply false
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.hilt) apply false
alias(libs.plugins.benchmark) apply false
Expand Down
1 change: 1 addition & 0 deletions core/designsystem/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id("naveenapps.plugin.kotlin.basic")
id("naveenapps.plugin.compose")
id("naveenapps.plugin.hilt")
alias(libs.plugins.compose.compiler)
}

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ data class TransactionCreateState(
enum class AccountSelection {
FROM_ACCOUNT,
TO_ACCOUNT
}
}

data class TransactionCreateInitSetupState(
val isCategorySyncCompleted: Boolean,
val isAccountSyncCompleted: Boolean,
)
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.firstOrNull
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import java.util.Calendar
Expand All @@ -63,6 +65,13 @@ class TransactionCreateViewModel @Inject constructor(

private val transactionType = MutableStateFlow(TransactionType.EXPENSE)

private val isInitialSyncCompleted = MutableStateFlow(
TransactionCreateInitSetupState(
isCategorySyncCompleted = false,
isAccountSyncCompleted = false
)
)

private val _state = MutableStateFlow(
TransactionCreateState(
amount = TextFieldValue(
Expand Down Expand Up @@ -137,6 +146,9 @@ class TransactionCreateViewModel @Inject constructor(
selectedToAccount = account ?: mappedAccounts.firstOrNull() ?: defaultAccount
)
}
isInitialSyncCompleted.update {
it.copy(isAccountSyncCompleted = true)
}
}.launchIn(viewModelScope)

combine(
Expand Down Expand Up @@ -178,9 +190,17 @@ class TransactionCreateViewModel @Inject constructor(
categories = filteredCategories
)
}

isInitialSyncCompleted.update {
it.copy(isCategorySyncCompleted = true)
}
}.launchIn(viewModelScope)

readInfo(savedStateHandle.get<String>(ExpenseManagerArgsNames.ID))
isInitialSyncCompleted.onEach {
if (it.isAccountSyncCompleted && it.isCategorySyncCompleted) {
readInfo(savedStateHandle.get<String>(ExpenseManagerArgsNames.ID))
}
}.distinctUntilChanged().launchIn(viewModelScope)
}

private fun readInfo(transactionId: String?) {
Expand All @@ -191,9 +211,11 @@ class TransactionCreateViewModel @Inject constructor(
is Resource.Success -> {
val transaction = response.data
this@TransactionCreateViewModel.transaction = transaction
this@TransactionCreateViewModel.transactionType.value = transaction.type
_state.update {
it.copy(
amount = it.amount.copy(value = transaction.amount.amount.toStringWithLocale()),
transactionType = transaction.type,
dateTime = transaction.createdOn,
notes = it.notes.copy(value = transaction.notes),
selectedFromAccount = transaction.fromAccount.toAccountUiModel(
Expand Down
38 changes: 28 additions & 10 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
accompanist = "0.34.0"
androidDesugarJdkLibs = "2.0.4"
androidGradlePlugin = "8.5.1"
androidxActivity = "1.9.0"
androidxActivity = "1.9.1"
androidxAppCompat = "1.7.0"
androidxMaterial = "1.12.0"
androidxBrowser = "1.7.0"
Expand All @@ -16,11 +16,11 @@ androidxCoreSplashscreen = "1.0.1"
androidxDataStore = "1.1.1"
androidxEspresso = "3.6.1"
androidxHiltNavigationCompose = "1.2.0"
androidxLifecycle = "2.8.3"
androidxLifecycle = "2.8.4"
androidxMacroBenchmark = "1.2.4"
benchmark = "1.2.4"
androidxMetrics = "1.0.0-beta01"
androidxNavigation = "2.8.0-beta05"
androidxNavigation = "2.8.0-beta06"
androidxProfileinstaller = "1.3.1"
androidxSplashScreen = "1.0.1"
androidxStartup = "1.1.1"
Expand All @@ -42,28 +42,28 @@ opencsv = "4.6"
review = "2.0.1"
googleOssPlugin = "0.10.6"
spotless = "6.23.0"
hilt = "2.51"
hilt = "2.51.1"
hiltExt = "1.2.0"
jacoco = "0.8.12"
junit4 = "4.13.2"
kotlin = "1.9.24"
kotlin = "2.0.0"
kotlinxCoroutines = "1.8.0"
kotlinxDatetime = "0.4.1"
kotlinxDatetime = "0.5.0"
kotlinxSerializationJson = "1.6.3"
ksp = "1.9.24-1.0.20"
ksp = "2.0.0-1.0.21"
lint = "31.5.1"
okhttp = "4.12.0"
retrofit = "2.9.0"
retrofitKotlinxSerializationJson = "1.0.0"
robolectric = "4.10.3"
robolectric = "4.12.2"
room = "2.6.1"
secrets = "2.0.1"
turbine = "1.0.0"
turbine = "1.1.0"
ossLicense = "0.10.5"
mpcharts = "v3.1.0"
mockito = "4.0.0"
jxl = "2.6.12"
truth = "1.1.4"
truth = "1.4.2"
vico = "1.11.1"
play-publish = "3.9.1"
google-services = "4.4.2"
Expand Down Expand Up @@ -190,6 +190,7 @@ firebase-distribution = { id = "com.google.firebase.appdistribution", version.re
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
secrets = { id = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin", version.ref = "secrets" }
oss-license = { id = "com.google.android.gms.oss-licenses-plugin", version.ref = "ossLicense" }
Expand All @@ -199,3 +200,20 @@ play-publish = { id = "com.github.triplet.play", version.ref = "play-publish" }
google-services = { id = "com.google.gms.google-services", version.ref = "google-services" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
dependency-analysis = { id = "com.autonomousapps.dependency-analysis", version.ref = "dependency-analysis" }


naveenapps-android-app = { id = "naveenapps.plugin.android.app", version = "unspecified" }
naveenapps-kotlin-basic = { id = "naveenapps.plugin.kotlin.basic", version = "unspecified" }
naveenapps-android-application-compose = { id = "naveenapps.android.application.compose", version = "unspecified" }
naveenapps-android-application-firebase = { id = "naveenapps.android.application.firebase", version = "unspecified" }
naveenapps-android-application-flavors = { id = "naveenapps.android.application.flavors", version = "unspecified" }
naveenapps-android-application-jacoco = { id = "naveenapps.android.application.jacoco", version = "unspecified" }
naveenapps-android-feature = { id = "naveenapps.android.feature", version = "unspecified" }
naveenapps-android-library = { id = "naveenapps.android.library", version = "unspecified" }
naveenapps-android-library-compose = { id = "naveenapps.android.library.compose", version = "unspecified" }
naveenapps-android-library-jacoco = { id = "naveenapps.android.library.jacoco", version = "unspecified" }
naveenapps-android-lint = { id = "naveenapps.android.lint", version = "unspecified" }
naveenapps-android-room = { id = "naveenapps.android.room", version = "unspecified" }
naveenapps-android-test = { id = "naveenapps.android.test", version = "unspecified" }
naveenapps-hilt = { id = "naveenapps.hilt", version = "unspecified" }
naveenapps-jvm-library = { id = "naveenapps.jvm.library", version = "unspecified" }

0 comments on commit 0f5c947

Please sign in to comment.