From 55bcccce8c2e66c9e53814f7d8ac94aa8a38c9b6 Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Sat, 1 Mar 2025 14:29:37 +0530 Subject: [PATCH] Migrating the ErrorActivity in jetpack. * Added the jetpack compose libraries in project. --- build.gradle.kts | 3 +- buildSrc/src/main/kotlin/Libs.kt | 39 +++++++++++++++++++ buildSrc/src/main/kotlin/Versions.kt | 12 ++++++ .../kotlin/plugin/AllProjectConfigurer.kt | 14 +++++++ core/build.gradle.kts | 4 ++ lintConfig.xml | 1 + 6 files changed, 72 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index e5c5dbcd0..2147bc5fe 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,6 +17,7 @@ buildscript { } plugins { buildSrcVersions + id("org.jetbrains.kotlin.plugin.compose") version Versions.ORG_JETBRAINS_KOTLIN_PLUGIN_COMPOSE apply false } allprojects { @@ -28,5 +29,5 @@ allprojects { } tasks.create("clean") { - delete(rootProject.buildDir) + delete(rootProject.layout.buildDirectory) } diff --git a/buildSrc/src/main/kotlin/Libs.kt b/buildSrc/src/main/kotlin/Libs.kt index 8de3a54d4..357f88556 100644 --- a/buildSrc/src/main/kotlin/Libs.kt +++ b/buildSrc/src/main/kotlin/Libs.kt @@ -366,4 +366,43 @@ object Libs { */ const val fetch: String = "com.github.tonyofrancis.Fetch:fetch2:" + Versions.fetch const val fetchOkhttp: String = "com.github.tonyofrancis.Fetch:fetch2okhttp:" + Versions.fetch + + /** + * https://developer.android.com/reference/kotlin/androidx/compose/material3 + */ + const val ANDROIDX_COMPOSE_MATERIAL3: String = + "androidx.compose.material3:material3-android:" + Versions.ANDROIDX_COMPOSE_MATERIAL3_VERSION + + /** + * https://developer.android.com/reference/kotlin/androidx/activity/compose + */ + const val ANDROIDX_ACTIVITY_COMPOSE: String = + "androidx.activity:activity-compose:" + Versions.ANDROIDX_ACTIVITY_COMPOSE_VERSION + + /** + * https://developer.android.com/develop/ui/compose/documentation + */ + const val ANDROIDX_COMPOSE_UI: String = + "androidx.compose.ui:ui:" + Versions.ANDROIDX_COMPOSE_UI_VERSION + + const val ANDROIDX_COMPOSE_BOM: String = + "androidx.compose:compose-bom:" + Versions.ANDROIDX_COMPOSE_BOM_VERSION + + const val ANDROIDX_COMPOSE_TOOLING_PREVIEW: String = + "androidx.compose.ui:ui-tooling-preview" + + const val ANDROIDX_COMPOSE_RUNTIME_LIVEDATA: String = + "androidx.compose.runtime:runtime-livedata" + + const val ANDROIDX_COMPOSE_RUNTIME_RXJAVA2: String = + "androidx.compose.runtime:runtime-rxjava2" + + /** + * testing libraries for compose + */ + const val ANDROIDX_COMPOSE_UI_TEST_JUNIT4: String = + "androidx.compose.ui:ui-test-junit4" + + const val ANDROIDX_COMPOSE_UI_TOOLING: String = + "androidx.compose.ui:ui-tooling" } diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index df019ada7..7145e0346 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -115,6 +115,18 @@ object Versions { const val keeper = "0.16.1" const val fetch: String = "3.4.1" + + const val ORG_JETBRAINS_KOTLIN_PLUGIN_COMPOSE = "2.1.10" + + const val KOTLIN_COMPILER_EXTENSION_VERSION = "1.5.15" + + const val ANDROIDX_COMPOSE_MATERIAL3_VERSION = "1.3.1" + + const val ANDROIDX_ACTIVITY_COMPOSE_VERSION = "1.10.0" + + const val ANDROIDX_COMPOSE_UI_VERSION = "1.7.7" + + const val ANDROIDX_COMPOSE_BOM_VERSION = "2025.01.01" } /** diff --git a/buildSrc/src/main/kotlin/plugin/AllProjectConfigurer.kt b/buildSrc/src/main/kotlin/plugin/AllProjectConfigurer.kt index 104480d1b..c379cb6b8 100644 --- a/buildSrc/src/main/kotlin/plugin/AllProjectConfigurer.kt +++ b/buildSrc/src/main/kotlin/plugin/AllProjectConfigurer.kt @@ -35,6 +35,7 @@ import org.jlleitschuh.gradle.ktlint.KtlintExtension class AllProjectConfigurer { fun applyPlugins(target: Project) { + target.plugins.apply("org.jetbrains.kotlin.plugin.compose") target.plugins.apply("kotlin-android") target.plugins.apply("kotlin-kapt") target.plugins.apply("com.google.devtools.ksp") @@ -90,6 +91,11 @@ class AllProjectConfigurer { * enabling this attribute will generate the `BuildConfig` file. */ buildConfig = true + compose = true + } + + composeOptions { + kotlinCompilerExtensionVersion = Versions.KOTLIN_COMPILER_EXTENSION_VERSION } testOptions { @@ -235,6 +241,14 @@ class AllProjectConfigurer { implementation(Libs.fetch) implementation(Libs.fetchOkhttp) implementation(Libs.androidx_activity) + + // compose + implementation(Libs.ANDROIDX_COMPOSE_MATERIAL3) + implementation(Libs.ANDROIDX_ACTIVITY_COMPOSE) + implementation(Libs.ANDROIDX_COMPOSE_UI) + implementation(Libs.ANDROIDX_COMPOSE_UI_TOOLING) + implementation(Libs.ANDROIDX_COMPOSE_RUNTIME_LIVEDATA) + implementation(Libs.ANDROIDX_COMPOSE_RUNTIME_RXJAVA2) } } } diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 20216805f..290c42ae7 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -63,4 +63,8 @@ dependencies { implementation(Libs.kotlinx_coroutines_android) implementation(Libs.kotlinx_coroutines_rx3) implementation(Libs.zxing) + implementation(platform(Libs.ANDROIDX_COMPOSE_BOM)) + // For Compose UI Testing + androidTestImplementation(Libs.ANDROIDX_COMPOSE_UI_TEST_JUNIT4) + debugImplementation(Libs.ANDROIDX_COMPOSE_UI_TOOLING) } diff --git a/lintConfig.xml b/lintConfig.xml index e043d2bdc..44af8acfc 100644 --- a/lintConfig.xml +++ b/lintConfig.xml @@ -51,4 +51,5 @@ +