-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate decompose progress di activityholder modules to KMP (#860)
**Background** Continue migration to KMP - core:progress, core:di, core:ui:decompose core:activityholder Also added custom gradle plugin to create dependencies with named scopes aka `commonMainDependencies` `dekstopMainDependencies` **Changes** - Refactored modules to support KMP - Added dependencies gradle plugin - Replace `kotlin.sourceSets.xxxMain.dependencies` to `xxxDependencies` - Move `:core:ktx:android-jre` into sharedJvmMain - Added build-konfig module to support KMP constants flags **Test plan** Green CI/CD
- Loading branch information
1 parent
d214311
commit 3287a46
Showing
60 changed files
with
433 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...ogic/plugins/convention/src/main/kotlin/com/flipperdevices/buildlogic/model/FlavorType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.flipperdevices.buildlogic.model | ||
|
||
/** | ||
* This enum is used to define new kotlin-generated BuildKonfig | ||
* | ||
* We already have multiple flavors for android - debug, internal, release | ||
* but android's flavor BuildConfig generation isn't compatible with KMP, | ||
* so in the end, when project will e KMP-full, this will be final version | ||
* of BuildKonfig field values | ||
*/ | ||
enum class FlavorType(val isLogEnabled: Boolean) { | ||
DEV(isLogEnabled = true), | ||
PROD(isLogEnabled = false) | ||
} |
36 changes: 36 additions & 0 deletions
36
...ain/kotlin/com/flipperdevices/buildlogic/plugin/FlipperMultiplatformDependenciesPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.flipperdevices.buildlogic.plugin | ||
|
||
import com.flipperdevices.buildlogic.util.ProjectExt.kotlin | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.create | ||
|
||
class FlipperMultiplatformDependenciesPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
target.kotlin.sourceSets.forEach { sourceSet -> | ||
val fullSourceSetName = sourceSet.name | ||
val noMainSourceSetName = if (fullSourceSetName.endsWith(MAIN_SOURCE_SET_POSTFIX)) { | ||
fullSourceSetName.replace( | ||
oldValue = MAIN_SOURCE_SET_POSTFIX, | ||
newValue = "" | ||
) | ||
} else { | ||
fullSourceSetName | ||
} | ||
|
||
target.extensions.create( | ||
"${noMainSourceSetName}Dependencies", | ||
FlipperMultiplatformDependenciesScope::class, | ||
target, | ||
fullSourceSetName | ||
) | ||
} | ||
} | ||
|
||
companion object { | ||
/** | ||
* The postfix of default source set naming aka commonMain, androidMain etc | ||
*/ | ||
private const val MAIN_SOURCE_SET_POSTFIX = "Main" | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...main/kotlin/com/flipperdevices/buildlogic/plugin/FlipperMultiplatformDependenciesScope.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
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 | ||
) |
16 changes: 16 additions & 0 deletions
16
...logic/plugins/convention/src/main/kotlin/com/flipperdevices/buildlogic/util/ProjectExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.flipperdevices.buildlogic.util | ||
|
||
import org.gradle.api.Project | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension | ||
|
||
internal object ProjectExt { | ||
/** | ||
* Required to remove gradle.kotlin.dsl.accessors dependency | ||
*/ | ||
val Project.kotlin: KotlinMultiplatformExtension | ||
get() { | ||
val extensionAware = (this as org.gradle.api.plugins.ExtensionAware) | ||
val kotlinExtension = extensionAware.extensions.getByName("kotlin") | ||
return kotlinExtension as KotlinMultiplatformExtension | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
plugins { | ||
id("flipper.android-lib") | ||
id("flipper.multiplatform") | ||
id("flipper.multiplatform-dependencies") | ||
} | ||
|
||
android.namespace = "com.flipperdevices.core.activityholder" | ||
|
||
dependencies { | ||
androidDependencies { | ||
implementation(libs.appcompat) | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import com.flipperdevices.buildlogic.ApkConfig.CURRENT_FLAVOR_TYPE | ||
|
||
plugins { | ||
id("flipper.multiplatform") | ||
id("flipper.multiplatform-dependencies") | ||
alias(libs.plugins.buildkonfig) | ||
} | ||
|
||
group = "com.flipperdevices.core.buildkonfig" | ||
|
||
android.namespace = "$group" | ||
|
||
buildConfig { | ||
className("BuildKonfig") | ||
packageName("$group") | ||
useKotlinOutput { internalVisibility = false } | ||
buildConfigField(String::class.java, "PACKAGE", "$group") | ||
buildConfigField(Boolean::class.java, "IS_LOG_ENABLED", CURRENT_FLAVOR_TYPE.isLogEnabled) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,17 @@ | ||
plugins { | ||
id("flipper.multiplatform") | ||
id("flipper.multiplatform-dependencies") | ||
} | ||
|
||
android.namespace = "com.flipperdevices.core.data" | ||
|
||
kotlin { | ||
sourceSets { | ||
commonMain.dependencies { | ||
implementation(libs.kotlin.immutable.collections) | ||
implementation(libs.compose.ui) | ||
} | ||
commonDependencies { | ||
implementation(libs.kotlin.immutable.collections) | ||
implementation(libs.compose.ui) | ||
} | ||
|
||
commonTest.dependencies { | ||
implementation(libs.junit) | ||
implementation(libs.mockito.kotlin) | ||
implementation(libs.ktx.testing) | ||
} | ||
} | ||
commonTestDependencies { | ||
implementation(libs.junit) | ||
implementation(libs.mockito.kotlin) | ||
implementation(libs.ktx.testing) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
plugins { | ||
id("flipper.android-lib") | ||
id("flipper.multiplatform") | ||
id("flipper.multiplatform-dependencies") | ||
} | ||
|
||
android.namespace = "com.flipperdevices.core.di" | ||
|
||
dependencies { | ||
commonDependencies { | ||
implementation(libs.dagger) | ||
} | ||
|
||
jvmSharedTestDependencies { | ||
implementation(libs.junit) | ||
implementation(libs.kotlin.coroutines.test) | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions
18
...src/jvmSharedTest/kotlin/com/flipperdevices/core/di/ComponentHolderJvmSharedSampleTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@file:Suppress("FunctionNaming") | ||
|
||
package com.flipperdevices.core.di | ||
|
||
import org.junit.Assert | ||
import org.junit.Test | ||
|
||
/** | ||
* This is a sample test class to demonstrate how to use jvmSharedTest source set | ||
*/ | ||
class ComponentHolderJvmSharedSampleTest { | ||
@Test | ||
fun GIVEN_empty_holder_WHEN_taking_int_class_THEN_throws() { | ||
Assert.assertThrows(Throwable::class.java) { | ||
ComponentHolder.component<Int>() | ||
} | ||
} | ||
} |
Oops, something went wrong.