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

KMP dependencies setup #2277

Merged
merged 4 commits into from
Jan 6, 2025
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
16 changes: 15 additions & 1 deletion build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies {
compileOnly(libs.firebase.crashlytics.gradlePlugin)
compileOnly(libs.firebase.performance.gradlePlugin)
compileOnly(libs.kotlin.gradlePlugin)
// compileOnly(libs.compose.gradlePlugin)
compileOnly(libs.compose.gradlePlugin)
compileOnly(libs.ksp.gradlePlugin)
compileOnly(libs.room.gradlePlugin)
compileOnly(libs.detekt.gradlePlugin)
Expand Down Expand Up @@ -118,5 +118,19 @@ gradlePlugin {
implementationClass = "MifosGitHooksConventionPlugin"
description = "Installs git hooks for the project"
}

// KMP & CMP Plugins
register("cmpFeature") {
id = "mifos.cmp.feature"
implementationClass = "CMPFeatureConventionPlugin"
}
register("kmpKoin") {
id = "mifos.kmp.koin"
implementationClass = "KMPKoinConventionPlugin"
}
register("kmpLibrary") {
id = "mifos.kmp.library"
implementationClass = "KMPLibraryConventionPlugin"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AndroidApplicationComposeConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
apply(plugin = "com.android.application")
// apply(plugin = "org.jetbrains.kotlin.plugin.compose")
apply(plugin = "org.jetbrains.kotlin.plugin.compose")

val extension = extensions.getByType<ApplicationExtension>()
configureAndroidCompose(extension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AndroidLibraryComposeConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
apply(plugin = "com.android.library")
// apply(plugin = "org.jetbrains.kotlin.plugin.compose")
apply(plugin = "org.jetbrains.kotlin.plugin.compose")

val extension = extensions.getByType<LibraryExtension>()
configureAndroidCompose(extension)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
import org.mifos.libs

class CMPFeatureConventionPlugin : Plugin<Project> {

override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("mifos.kmp.libray")
apply("mifos.kmp.koin")
apply("org.jetbrains.kotlin.plugin.compose")
apply("org.jetbrains.compose")
}

dependencies {
add("commonMainImplementation", project(":core:ui"))
add("commonMainImplementation", project(":core:designsystem"))
add("commonMainImplementation", project(":core:testing"))
add("commonMainImplementation", project(":core:data"))

add("commonMainImplementation", libs.findLibrary("koin.compose").get())
add("commonMainImplementation", libs.findLibrary("koin.compose.viewmodel").get())

add("commonMainImplementation", libs.findLibrary("jb.composeRuntime").get())
add("commonMainImplementation", libs.findLibrary("jb.composeViewmodel").get())
add("commonMainImplementation", libs.findLibrary("jb.lifecycleViewmodel").get())
add("commonMainImplementation", libs.findLibrary("jb.lifecycleViewmodelSavedState").get())
add("commonMainImplementation", libs.findLibrary("jb.savedstate").get())
add("commonMainImplementation", libs.findLibrary("jb.bundle").get())
add("commonMainImplementation", libs.findLibrary("jb.composeNavigation").get())
add("commonMainImplementation", libs.findLibrary("kotlinx.collections.immutable").get())

add("androidMainImplementation", libs.findLibrary("androidx.lifecycle.runtimeCompose").get())
add("androidMainImplementation", libs.findLibrary("androidx.lifecycle.viewModelCompose").get())
add("androidMainImplementation", libs.findLibrary("androidx.tracing.ktx").get())

add("androidMainImplementation", platform(libs.findLibrary("koin-bom").get()))
add("androidMainImplementation", libs.findLibrary("koin-android").get())
add("androidMainImplementation", libs.findLibrary("koin.androidx.compose").get())

add("androidMainImplementation", libs.findLibrary("koin.android").get())
add("androidMainImplementation", libs.findLibrary("koin.androidx.navigation").get())
add("androidMainImplementation", libs.findLibrary("koin.androidx.compose").get())
add("androidMainImplementation", libs.findLibrary("koin.core.viewmodel").get())

add("androidTestImplementation", libs.findLibrary("koin.test.junit4").get())

add("androidInstrumentedTestImplementation", libs.findLibrary("androidx.navigation.testing").get())
add("androidInstrumentedTestImplementation", libs.findLibrary("androidx.compose.ui.test").get())
add("androidInstrumentedTestImplementation", libs.findLibrary("androidx.lifecycle.runtimeTesting").get())
}
}
}
}
25 changes: 25 additions & 0 deletions build-logic/convention/src/main/kotlin/KMPKoinConventionPlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
import org.mifos.libs

class KMPKoinConventionPlugin : Plugin<Project> {

override fun apply(target: Project) {
with(target){
with(pluginManager){
apply("com.google.devtools.ksp")
}

dependencies {
val bom = libs.findLibrary("koin-bom").get()
add("commonMainImplementation", platform(bom))
add("commonMainImplementation", libs.findLibrary("koin.core").get())
add("commonMainImplementation", libs.findLibrary("koin.annotations").get())
add("kspCommonMainMetadata", libs.findLibrary("koin.ksp.compiler").get())
add("commonTestImplementation", libs.findLibrary("koin.test").get())
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import com.android.build.gradle.LibraryExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
import org.mifos.configureFlavors
import org.mifos.configureKotlinAndroid
import org.mifos.configureKotlinMultiplatform
import org.mifos.libs

class KMPLibraryConventionPlugin : Plugin<Project> {

override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.android.library")
apply("org.jetbrains.kotlin.multiplatform")
apply("mifos.kmp.koin")
apply("mifos.detekt.plugin")
apply("mifos.spotless.plugin")
}

configureKotlinMultiplatform()

extensions.configure<LibraryExtension> {
configureKotlinAndroid(this)
defaultConfig.targetSdk = 34
configureFlavors(this)
/**
* The resource prefix is derived from the module name,
* so resources inside ":core:module1" must be prefixed with "core_module1_"
*/
resourcePrefix = path
.split("""\W""".toRegex())
.drop(1).distinct()
.joinToString(separator = "_")
.lowercase() + "_"
}

dependencies {
add("commonTestImplementation", libs.findLibrary("kotlin.test").get())
add("commonTestImplementation", libs.findLibrary("kotlinx.coroutines.test").get())
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.mifos

import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension

@OptIn(ExperimentalWasmDsl::class, ExperimentalKotlinGradlePluginApi::class)
internal fun Project.configureKotlinMultiplatform() {
extensions.configure<KotlinMultiplatformExtension> {
applyDefaultHierarchyTemplate()

jvm("desktop")
androidTarget()
iosSimulatorArm64()
iosX64()
iosArm64()
js(IR) {
this.nodejs()
binaries.executable()
}
wasmJs() {
browser()
nodejs()
}

compilerOptions {
freeCompilerArgs.add("-Xexpect-actual-classes")
}
}
}
7 changes: 7 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,11 @@ plugins {
alias(libs.plugins.detekt) apply false
alias(libs.plugins.spotless) apply false
alias(libs.plugins.ktlint) apply false

//Multiplatform Plugins
alias(libs.plugins.jetbrainsCompose) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.wire) apply false
alias(libs.plugins.ktorfit) apply false
}
5 changes: 5 additions & 0 deletions compose_compiler_config.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This file contains classes (with possible wildcards) that the Compose Compiler will treat as stable.
// It allows us to define classes that our not part of our codebase without wrapping them in a stable class.
// For more information, check https://developer.android.com/jetpack/compose/performance/stability/fix#configuration-file

java.time.ZoneOffset
2 changes: 1 addition & 1 deletion core/designsystem/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ dependencies {

androidTestImplementation(libs.androidx.compose.ui.test)
androidTestImplementation(projects.core.testing)
}
}
21 changes: 18 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ androidDesugarJdkLibs = "2.0.4"
androidIconifyMaterial = "2.2.2"
androidJob = "1.2.6"
androidMapsUtils = "0.4.2"
androidGradlePlugin = "8.5.0"
androidGradlePlugin = "8.5.2"
androidTools = "31.6.0"
androidxActivity = "1.8.2"
androidxAppCompat = "1.6.1"
Expand Down Expand Up @@ -66,7 +66,7 @@ jacoco = "0.8.7"
junit4 = "4.13.2"
junitJupiter = "5.8.2"
junitVersion = "1.1.5"
kotlin = "1.9.22"
kotlin = "2.0.21"
kotlinxCoroutines = "1.7.3"
kotlinxCoroutinesCoreVersion = "1.5.1"
kotlinxCoroutinesRx2 = "1.5.1"
Expand Down Expand Up @@ -131,6 +131,14 @@ truthVersion = '1.1.5'
runtimeLivedata = "1.6.8"
appcompat = "1.7.0"

# Ktor & Ktorfit
ktorfit = "2.2.0"

# CMP Libraries
compose-plugin = "1.7.0-rc01"
wire = "5.0.0"
coil-cmp = "3.0.4"

[libraries]
# AndroidX Libraries
accompanist-drawablepainter = { module = "com.google.accompanist:accompanist-drawablepainter", version.ref = "accompanistDrawablepainter" }
Expand Down Expand Up @@ -415,7 +423,6 @@ kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-kapt = { id = "kotlin-kapt", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
kotlin-parcelize = { id = "kotlin-parcelize", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
protobuf = { id = "com.google.protobuf", version.ref = "protobufPlugin" }
realm = { id = "io.realm.kotlin", version.ref = "realmVersion" }
secrets = { id = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin", version.ref = "secrets" }
Expand All @@ -424,6 +431,14 @@ ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotlessVersion" }
dependencyGuard = { id = "com.dropbox.dependency-guard", version.ref = "dependencyGuard" }

# KMP & CMP
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
ktorfit = { id = "de.jensklingenberg.ktorfit", version.ref = "ktorfit" }
wire = { id = "com.squareup.wire", version.ref = "wire" }

# Plugins defined by this project
mifos-android-application = { id = "mifos.android.application", version = "unspecified" }
mifos-android-application-flavors = { id = "mifos.android.application.flavors", version = "unspecified" }
Expand Down
12 changes: 6 additions & 6 deletions mifosng-android/dependencies/demoDebugCompileClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ androidx.core:core-splashscreen:1.0.1
androidx.core:core:1.13.0
androidx.cursoradapter:cursoradapter:1.0.0
androidx.customview:customview:1.1.0
androidx.databinding:viewbinding:8.5.0
androidx.databinding:viewbinding:8.5.2
androidx.documentfile:documentfile:1.0.0
androidx.drawerlayout:drawerlayout:1.1.1
androidx.dynamicanimation:dynamicanimation:1.0.0
Expand Down Expand Up @@ -192,11 +192,11 @@ io.reactivex:rxjava:1.3.8
javax.inject:javax.inject:1
junit:junit:4.13.2
org.hamcrest:hamcrest-core:1.3
org.jetbrains.kotlin:kotlin-stdlib-common:2.0.0
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.0
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.0
org.jetbrains.kotlin:kotlin-stdlib:2.0.0
org.jetbrains.kotlin:kotlin-test:1.9.22
org.jetbrains.kotlin:kotlin-stdlib-common:2.0.21
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21
org.jetbrains.kotlin:kotlin-stdlib:2.0.21
org.jetbrains.kotlin:kotlin-test:2.0.21
org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.8.0
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.8.0
Expand Down
12 changes: 6 additions & 6 deletions mifosng-android/dependencies/demoReleaseCompileClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ androidx.core:core-splashscreen:1.0.1
androidx.core:core:1.13.0
androidx.cursoradapter:cursoradapter:1.0.0
androidx.customview:customview:1.1.0
androidx.databinding:viewbinding:8.5.0
androidx.databinding:viewbinding:8.5.2
androidx.documentfile:documentfile:1.0.0
androidx.drawerlayout:drawerlayout:1.1.1
androidx.dynamicanimation:dynamicanimation:1.0.0
Expand Down Expand Up @@ -187,11 +187,11 @@ io.reactivex:rxjava:1.3.8
javax.inject:javax.inject:1
junit:junit:4.13.2
org.hamcrest:hamcrest-core:1.3
org.jetbrains.kotlin:kotlin-stdlib-common:2.0.0
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.0
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.0
org.jetbrains.kotlin:kotlin-stdlib:2.0.0
org.jetbrains.kotlin:kotlin-test:1.9.22
org.jetbrains.kotlin:kotlin-stdlib-common:2.0.21
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21
org.jetbrains.kotlin:kotlin-stdlib:2.0.21
org.jetbrains.kotlin:kotlin-test:2.0.21
org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.8.0
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.8.0
Expand Down
12 changes: 6 additions & 6 deletions mifosng-android/dependencies/prodDebugCompileClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ androidx.core:core-splashscreen:1.0.1
androidx.core:core:1.13.0
androidx.cursoradapter:cursoradapter:1.0.0
androidx.customview:customview:1.1.0
androidx.databinding:viewbinding:8.5.0
androidx.databinding:viewbinding:8.5.2
androidx.documentfile:documentfile:1.0.0
androidx.drawerlayout:drawerlayout:1.1.1
androidx.dynamicanimation:dynamicanimation:1.0.0
Expand Down Expand Up @@ -192,11 +192,11 @@ io.reactivex:rxjava:1.3.8
javax.inject:javax.inject:1
junit:junit:4.13.2
org.hamcrest:hamcrest-core:1.3
org.jetbrains.kotlin:kotlin-stdlib-common:2.0.0
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.0
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.0
org.jetbrains.kotlin:kotlin-stdlib:2.0.0
org.jetbrains.kotlin:kotlin-test:1.9.22
org.jetbrains.kotlin:kotlin-stdlib-common:2.0.21
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21
org.jetbrains.kotlin:kotlin-stdlib:2.0.21
org.jetbrains.kotlin:kotlin-test:2.0.21
org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.8.0
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.8.0
Expand Down
12 changes: 6 additions & 6 deletions mifosng-android/dependencies/prodReleaseCompileClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ androidx.core:core-splashscreen:1.0.1
androidx.core:core:1.13.0
androidx.cursoradapter:cursoradapter:1.0.0
androidx.customview:customview:1.1.0
androidx.databinding:viewbinding:8.5.0
androidx.databinding:viewbinding:8.5.2
androidx.documentfile:documentfile:1.0.0
androidx.drawerlayout:drawerlayout:1.1.1
androidx.dynamicanimation:dynamicanimation:1.0.0
Expand Down Expand Up @@ -187,11 +187,11 @@ io.reactivex:rxjava:1.3.8
javax.inject:javax.inject:1
junit:junit:4.13.2
org.hamcrest:hamcrest-core:1.3
org.jetbrains.kotlin:kotlin-stdlib-common:2.0.0
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.0
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.0
org.jetbrains.kotlin:kotlin-stdlib:2.0.0
org.jetbrains.kotlin:kotlin-test:1.9.22
org.jetbrains.kotlin:kotlin-stdlib-common:2.0.21
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21
org.jetbrains.kotlin:kotlin-stdlib:2.0.21
org.jetbrains.kotlin:kotlin-test:2.0.21
org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.8.0
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.8.0
Expand Down
Loading
Loading