diff --git a/.github/workflows/lint.yaml b/.github/workflows/CI.yaml similarity index 74% rename from .github/workflows/lint.yaml rename to .github/workflows/CI.yaml index a6b05a6..55f78da 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/CI.yaml @@ -1,10 +1,10 @@ -name: Lint and verify +name: CI on: pull_request: workflow_dispatch: jobs: - lint: + ci: runs-on: ubuntu-latest steps: @@ -20,15 +20,9 @@ jobs: - name: Validate Gradle wrapper uses: gradle/wrapper-validation-action@v1.1.0 - - name: Build Project with Gradle + - name: Setup Gradle Gradle uses: gradle/gradle-build-action@v2.1.0 - - name: Lint - run: ./gradlew clean ktlintCheck - - - name: Tests - run: ./gradlew :shared:testReleaseUnitTest - - name: Build Project run: ./gradlew build diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts index 2a46f2d..9bf282a 100644 --- a/androidApp/build.gradle.kts +++ b/androidApp/build.gradle.kts @@ -1,8 +1,8 @@ plugins { - kotlin("multiplatform") - id("com.android.application") - id("org.jetbrains.compose") - id("com.google.gms.google-services") + alias(libs.plugins.kotlin.multiplatform) + alias(libs.plugins.android.application) + alias(libs.plugins.compose) + alias(libs.plugins.google.services) } kotlin { @@ -11,12 +11,12 @@ kotlin { androidMain { dependencies { implementation(project(":shared")) - implementation("androidx.activity:activity-compose:1.8.1") - implementation("androidx.core:core-ktx:1.12.0") + implementation(libs.activity.compose) + implementation(libs.core.ktx) - implementation(project.dependencies.platform("com.google.firebase:firebase-bom:${Versions.FIREBASE_BOM}")) - implementation("com.google.firebase:firebase-analytics-ktx") - implementation("com.google.firebase:firebase-messaging-ktx") + implementation(project.dependencies.platform(libs.firebase.bom)) + implementation(libs.firebase.analytics) + implementation(libs.firebase.messaging) } } } @@ -30,7 +30,7 @@ android { defaultConfig { applicationId = Artifact.APP_ID - minSdk = Artifact.ANDROID_MIN_SDK + minSdk = Artifact.ANDROID_MIN_SDK targetSdk = Artifact.ANDROID_TARGET_SDK versionCode = Artifact.VERSION_CODE diff --git a/build.gradle.kts b/build.gradle.kts index d2d5777..f1c765b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,18 +2,18 @@ import org.jlleitschuh.gradle.ktlint.KtlintExtension import org.jlleitschuh.gradle.ktlint.KtlintPlugin plugins { - kotlin("jvm") version Versions.KOTLIN apply false - kotlin("multiplatform") version Versions.KOTLIN apply false - kotlin("android") version Versions.KOTLIN apply false - kotlin("plugin.serialization") version Versions.KOTLIN apply false - id("com.android.application") version Versions.AGP apply false - id("com.android.library") version Versions.AGP apply false - id("org.jetbrains.compose") version Versions.COMPOSE apply false - id("com.adarshr.test-logger") version "3.2.0" apply false - id("org.jlleitschuh.gradle.ktlint") version "11.5.0" apply true - id("com.codingfeline.buildkonfig") version "0.14.0" apply false - id("app.cash.sqldelight") version Versions.SQLDELIGHT apply false - id("com.google.gms.google-services") version "4.3.15" apply false + alias(libs.plugins.kotlin.jvm) apply false + alias(libs.plugins.kotlin.multiplatform) apply false + alias(libs.plugins.kotlin.android) apply false + alias(libs.plugins.kotlin.serialization) apply false + alias(libs.plugins.android.application) apply false + alias(libs.plugins.android.library) apply false + alias(libs.plugins.compose) apply false + alias(libs.plugins.test.logger) apply false + alias(libs.plugins.ktlint) apply false + alias(libs.plugins.buildkonfig) apply false + alias(libs.plugins.sqldelight) apply false + alias(libs.plugins.google.services) apply false } allprojects { diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts new file mode 100644 index 0000000..215a5d5 --- /dev/null +++ b/buildSrc/settings.gradle.kts @@ -0,0 +1,7 @@ +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } +} diff --git a/buildSrc/src/main/kotlin/Artifacts.kt b/buildSrc/src/main/kotlin/Artifacts.kt index 16d0667..b595350 100644 --- a/buildSrc/src/main/kotlin/Artifacts.kt +++ b/buildSrc/src/main/kotlin/Artifacts.kt @@ -1,6 +1,5 @@ object Artifact { const val APP_ID = "me.sujanpoudel.playdeals" - const val APP_NAME = "App Deals" const val VERSION_CODE = 30 const val VERSION_NAME = "2.1.5" const val MAJOR_RELEASE = false diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt deleted file mode 100644 index c5889a3..0000000 --- a/buildSrc/src/main/kotlin/Versions.kt +++ /dev/null @@ -1,18 +0,0 @@ -object Versions { - const val KOTLIN = "1.9.20" - const val AGP = "8.2.0" - const val COMPOSE = "1.5.11" - const val COMPOSE_COMPILER_VERSION = "1.5.6" - const val SETTINGS = "1.0.0" - const val SQLDELIGHT = "2.0.0" - const val FIREBASE_BOM = "32.3.1" - - const val KTOR = "2.3.6" - const val KODE_IN = "7.20.2" - const val COROUTINE = "1.7.3" - const val KOTLINX_DATE_TIME = "0.4.1" - - const val JUNIT_JUPITER = "5.9.3" - const val MOCKK = "1.13.8" - const val KO_TEST = "5.5.5" -} diff --git a/desktopApp/build.gradle.kts b/desktopApp/build.gradle.kts index 93f124d..b278f80 100644 --- a/desktopApp/build.gradle.kts +++ b/desktopApp/build.gradle.kts @@ -1,8 +1,8 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat plugins { - kotlin("multiplatform") - id("org.jetbrains.compose") + alias(libs.plugins.kotlin.multiplatform) + alias(libs.plugins.compose) } kotlin { @@ -13,7 +13,7 @@ kotlin { dependencies { implementation(compose.desktop.currentOs) implementation(project(":shared")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-swing:${Versions.COROUTINE}") + implementation(libs.kotlinx.coroutines.swing) } } } diff --git a/gradle.properties b/gradle.properties index bc2ecec..4965c82 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,6 +2,7 @@ kotlin.code.style=official # gradle org.gradle.jvmargs=-Xmx3g +org.gradle.caching=true # android android.useAndroidX=true android.nonTransitiveRClass=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..291ab4d --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,101 @@ +[versions] + +# Plugins +kotlin = "1.9.21" +agp = "8.2.0" +compose = "1.5.11" +test-logger = "3.2.0" +klint = "11.5.0" +buildkonfig = "0.14.0" +sqldelight = "2.0.0" +google-services = "4.4.0" + +# Libraries +compose-compiler = "1.5.6" +accompanist-permissions = "0.32.0" +activity-compose = "1.8.2" +appcompat = "1.6.1" +core-ktx = "1.12.0" +startup-runtime = "1.1.1" + +kotlinx-coroutines-core = "1.7.3" +kotlinx-datetime = "0.5.0" +coroutines-extensions = "2.0.0-alpha05" +kotlinxIoCore = "0.3.0" + +firebase-bom = "32.7.0" + +ktor-client-logging = "2.3.6" +ktor-serialization-kotlinx-json = "2.3.6" +ktor-client-content-negotiation = "2.3.6" +ktor-client-core = "2.3.6" + +kamel-image = "0.8.3" +kodein-di = "7.20.2" +multiplatform-markdown-renderer = "0.7.2" +multiplatform-settings = "1.0.0" +mp-utils = "0.1.0" + +# Testing +junit-jupiter = "5.9.3" +kotest-assertions-core = "5.5.5" +mockk = "1.13.8" + +[plugins] +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } +kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +android-application = { id = "com.android.application", version.ref = "agp" } +android-library = { id = "com.android.library", version.ref = "agp" } +google-services = { id = "com.google.gms.google-services", version.ref = "google-services" } +compose = { id = "org.jetbrains.compose", version.ref = "compose" } +ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "klint" } +test-logger = { id = "com.adarshr.test-logger", version.ref = "test-logger" } +buildkonfig = { id = "com.codingfeline.buildkonfig", version.ref = "buildkonfig" } +sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" } + + +[libraries] +accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", version.ref = "accompanist-permissions" } +activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activity-compose" } +appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" } +core-ktx = { module = "androidx.core:core-ktx", version.ref = "core-ktx" } +startup-runtime = { module = "androidx.startup:startup-runtime", version.ref = "startup-runtime" } + +kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines-core" } +kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" } +kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "kotlinx-coroutines-core" } +kotlinx-io-core = { module = "org.jetbrains.kotlinx:kotlinx-io-core", version.ref = "kotlinxIoCore" } + +firebase-bom = { module = "com.google.firebase:firebase-bom", version.ref = "firebase-bom" } +firebase-analytics = { module = "com.google.firebase:firebase-analytics-ktx" } +firebase-messaging = { module = "com.google.firebase:firebase-messaging-ktx" } + +ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor-client-logging" } +ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor-serialization-kotlinx-json" } +ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor-client-content-negotiation" } +ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor-client-core" } +ktor-client-android = { module = "io.ktor:ktor-client-android", version.ref = "ktor-client-logging" } +ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor-client-logging" } +ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor-client-logging" } + +sqldelight-coroutines-extensions = { module = "app.cash.sqldelight:coroutines-extensions", version.ref = "coroutines-extensions" } +sqldelight-primitive-adapters = { module = "app.cash.sqldelight:primitive-adapters", version.ref = "coroutines-extensions" } +sqldelight-android-driver = { module = "app.cash.sqldelight:android-driver", version.ref = "sqldelight" } +sqldelight-native-driver = { module = "app.cash.sqldelight:native-driver", version.ref = "sqldelight" } +sqldelight-sqlite-driver = { module = "app.cash.sqldelight:sqlite-driver", version.ref = "sqldelight" } +kamel-image = { module = "media.kamel:kamel-image", version.ref = "kamel-image" } +kodein-di = { module = "org.kodein.di:kodein-di", version.ref = "kodein-di" } +multiplatform-markdown-renderer = { module = "com.mikepenz:multiplatform-markdown-renderer", version.ref = "multiplatform-markdown-renderer" } +multiplatform-settings = { module = "com.russhwolf:multiplatform-settings", version.ref = "multiplatform-settings" } +multiplatform-settings-no-arg = { module = "com.russhwolf:multiplatform-settings-no-arg", version.ref = "multiplatform-settings" } + +mputils-paths = { module = "me.sujanpoudel.mputils:paths", version.ref = "mp-utils" } + +kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines-core" } +junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" } +kotest-assertions-core = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest-assertions-core" } +mockk = { module = "io.mockk:mockk", version.ref = "mockk" } +multiplatform-settings-test = { module = "com.russhwolf:multiplatform-settings-test", version.ref = "multiplatform-settings" } + diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index 6204d58..74b571f 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -5,16 +5,15 @@ import com.codingfeline.buildkonfig.compiler.FieldSpec.Type.STRING import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget plugins { - kotlin("multiplatform") - kotlin("plugin.serialization") - id("com.android.library") - id("org.jetbrains.compose") - id("com.adarshr.test-logger") - id("com.codingfeline.buildkonfig") - id("app.cash.sqldelight") + alias(libs.plugins.kotlin.multiplatform) + alias(libs.plugins.kotlin.serialization) + alias(libs.plugins.android.library) + alias(libs.plugins.compose) + alias(libs.plugins.test.logger) + alias(libs.plugins.buildkonfig) + alias(libs.plugins.sqldelight) } -version = "1.0-SNAPSHOT" val pkgName = "me.sujanpoudel.playdeals.common" @@ -33,7 +32,7 @@ kotlin { jvm("desktop") iosArm64() { configureFramework() } - iosX64() { configureFramework() } +// iosX64() { configureFramework() } iosSimulatorArm64().configureFramework() sourceSets { @@ -47,37 +46,39 @@ kotlin { implementation(compose.materialIconsExtended) @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) implementation(compose.components.resources) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.COROUTINE}") - implementation("org.jetbrains.kotlinx:kotlinx-datetime:${Versions.KOTLINX_DATE_TIME}") + implementation(libs.kotlinx.coroutines.core) + implementation(libs.kotlinx.datetime) - api("org.kodein.di:kodein-di:${Versions.KODE_IN}") + api(libs.kodein.di) - implementation("io.ktor:ktor-client-core:${Versions.KTOR}") - implementation("io.ktor:ktor-client-content-negotiation:${Versions.KTOR}") - implementation("io.ktor:ktor-serialization-kotlinx-json:${Versions.KTOR}") - implementation("io.ktor:ktor-client-logging:${Versions.KTOR}") + implementation(libs.ktor.client.core) + implementation(libs.ktor.client.content.negotiation) + implementation(libs.ktor.serialization.kotlinx.json) + implementation(libs.ktor.client.logging) - implementation("media.kamel:kamel-image:0.8.3") - implementation("com.russhwolf:multiplatform-settings:${Versions.SETTINGS}") - implementation("com.russhwolf:multiplatform-settings-no-arg:${Versions.SETTINGS}") + implementation(libs.kamel.image) + implementation(libs.multiplatform.settings) + implementation(libs.multiplatform.settings.no.arg) - implementation("com.mikepenz:multiplatform-markdown-renderer:0.7.2") - implementation("app.cash.sqldelight:coroutines-extensions:2.0.0-alpha05") - implementation("app.cash.sqldelight:primitive-adapters:2.0.0-alpha05") + implementation(libs.multiplatform.markdown.renderer) + implementation(libs.sqldelight.coroutines.extensions) + implementation(libs.sqldelight.primitive.adapters) + + implementation(libs.kotlinx.io.core) } } androidMain { dependencies { - implementation("io.ktor:ktor-client-android:${Versions.KTOR}") - implementation("androidx.appcompat:appcompat:1.6.1") - implementation("app.cash.sqldelight:android-driver:${Versions.SQLDELIGHT}") - implementation("androidx.startup:startup-runtime:1.1.1") - implementation("com.google.accompanist:accompanist-permissions:0.32.0") - - implementation(project.dependencies.platform("com.google.firebase:firebase-bom:${Versions.FIREBASE_BOM}")) - implementation("com.google.firebase:firebase-analytics-ktx") - implementation("com.google.firebase:firebase-messaging-ktx") + implementation(libs.ktor.client.android) + implementation(libs.appcompat) + implementation(libs.sqldelight.android.driver) + implementation(libs.startup.runtime) + implementation(libs.accompanist.permissions) + + implementation(project.dependencies.platform(libs.firebase.bom)) + implementation(libs.firebase.analytics) + implementation(libs.firebase.messaging) } } @@ -85,18 +86,18 @@ kotlin { dependsOn(commonTest.get()) dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${Versions.COROUTINE}") - implementation("io.kotest:kotest-assertions-core:${Versions.KO_TEST}") - implementation("io.mockk:mockk:${Versions.MOCKK}") - implementation("org.junit.jupiter:junit-jupiter:${Versions.JUNIT_JUPITER}") - implementation("com.russhwolf:multiplatform-settings-test:${Versions.SETTINGS}") + implementation(libs.kotlinx.coroutines.test) + implementation(libs.kotest.assertions.core) + implementation(libs.mockk) + implementation(libs.junit.jupiter) + implementation(libs.multiplatform.settings.test) } } iosMain { dependencies { - implementation("io.ktor:ktor-client-darwin:${Versions.KTOR}") - implementation("app.cash.sqldelight:native-driver:${Versions.SQLDELIGHT}") + implementation(libs.ktor.client.darwin) + implementation(libs.sqldelight.native.driver) } } @@ -107,8 +108,9 @@ kotlin { val desktopMain by getting { dependencies { implementation(compose.desktop.common) - implementation("io.ktor:ktor-client-okhttp:${Versions.KTOR}") - implementation("app.cash.sqldelight:sqlite-driver:${Versions.SQLDELIGHT}") + implementation(libs.ktor.client.okhttp) + implementation(libs.sqldelight.sqlite.driver) + implementation(libs.mputils.paths) } } } @@ -132,7 +134,7 @@ android { } composeOptions { - kotlinCompilerExtensionVersion = Versions.COMPOSE_COMPILER_VERSION + kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get() } compileOptions { diff --git a/shared/src/desktopMain/kotlin/me/sujanpoudel/playdeals/common/domain/persistent/db/sqlDriver.desktop.kt b/shared/src/desktopMain/kotlin/me/sujanpoudel/playdeals/common/domain/persistent/db/sqlDriver.desktop.kt index 46963d3..245eb94 100644 --- a/shared/src/desktopMain/kotlin/me/sujanpoudel/playdeals/common/domain/persistent/db/sqlDriver.desktop.kt +++ b/shared/src/desktopMain/kotlin/me/sujanpoudel/playdeals/common/domain/persistent/db/sqlDriver.desktop.kt @@ -3,11 +3,18 @@ package me.sujanpoudel.playdeals.common.domain.persistent.db import app.cash.sqldelight.async.coroutines.synchronous import app.cash.sqldelight.db.SqlDriver import app.cash.sqldelight.driver.jdbc.sqlite.JdbcSqliteDriver +import me.sujanpoudel.mputils.paths.appDataDirectory +import me.sujanpoudel.mputils.paths.utils.div +import me.sujanpoudel.playdeals.common.BuildKonfig import me.sujanpoudel.playdeals.common.Constants import me.sujanpoudel.playdeals.common.SqliteDatabase -actual fun createSqlDriver(): SqlDriver = JdbcSqliteDriver( - url = "jdbc:sqlite:${Constants.DATABASE_NAME}", - schema = SqliteDatabase.Schema.synchronous(), - migrateEmptySchema = true, -) +actual fun createSqlDriver(): SqlDriver { + val path = appDataDirectory(BuildKonfig.PACKAGE_NAME) / Constants.DATABASE_NAME + + return JdbcSqliteDriver( + url = "jdbc:sqlite:$path", + schema = SqliteDatabase.Schema.synchronous(), + migrateEmptySchema = true, + ) +} diff --git a/strip_google_services.sh b/strip_google_services.sh index fccea92..35a6cca 100755 --- a/strip_google_services.sh +++ b/strip_google_services.sh @@ -5,5 +5,5 @@ sed -i'.bak' -e '26,34d;' androidApp/src/androidMain/AndroidManifest.xml rm androidApp/src/androidMain/kotlin/me/sujanpoudel/playdeals/FcmService.kt sed -i'.bak' -e '5d;14d;18d;' shared/src/androidMain/kotlin/me/sujanpoudel/playdeals/common/pushNotification/AndroidNotificationManager.kt -sed -i'.bak' -e '78,80d;' shared/build.gradle.kts +sed -i'.bak' -e '79,81d;' shared/build.gradle.kts sed -i'.bak' -e '16d;' build.gradle.kts