diff --git a/features/common/.gitignore b/features/common/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/features/common/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/features/common/build.gradle.kts b/features/common/build.gradle.kts new file mode 100644 index 0000000..acc77ed --- /dev/null +++ b/features/common/build.gradle.kts @@ -0,0 +1,37 @@ +plugins { + alias(libs.plugins.kotlinDevKit) + alias(libs.plugins.composeDevKit) +} + +kotlin { + androidLibrary { + withHostTestBuilder { + } + + withDeviceTestBuilder { + sourceSetTreeName = "test" + }.configure { + instrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + } + + sourceSets { + commonMain { + dependencies { + // Add KMP-specific dependencies here. + } + } + + androidMain { + dependencies { + // Add Android-specific dependencies here. + } + } + + iosMain { + dependencies { + // Add iOS-specific dependencies here. + } + } + } +} diff --git a/features/common/src/androidDeviceTest/kotlin/dev/carlosmartino/common/ExampleInstrumentedTest.kt b/features/common/src/androidDeviceTest/kotlin/dev/carlosmartino/common/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..16b299c --- /dev/null +++ b/features/common/src/androidDeviceTest/kotlin/dev/carlosmartino/common/ExampleInstrumentedTest.kt @@ -0,0 +1,21 @@ +package dev.carlosmartino.common + +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.platform.app.InstrumentationRegistry +import org.junit.Test +import org.junit.runner.RunWith + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("dev.carlosmartino.common.test", appContext.packageName) + } +} diff --git a/features/common/src/androidHostTest/kotlin/dev/carlosmartino/common/ExampleUnitTest.kt b/features/common/src/androidHostTest/kotlin/dev/carlosmartino/common/ExampleUnitTest.kt new file mode 100644 index 0000000..dc287e8 --- /dev/null +++ b/features/common/src/androidHostTest/kotlin/dev/carlosmartino/common/ExampleUnitTest.kt @@ -0,0 +1,16 @@ +package dev.carlosmartino.common + +import kotlin.test.Test +import kotlin.test.assertEquals + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/features/common/src/androidMain/AndroidManifest.xml b/features/common/src/androidMain/AndroidManifest.xml new file mode 100644 index 0000000..a5918e6 --- /dev/null +++ b/features/common/src/androidMain/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/features/common/src/androidMain/kotlin/dev/carlosmartino/common/Platform.android.kt b/features/common/src/androidMain/kotlin/dev/carlosmartino/common/Platform.android.kt new file mode 100644 index 0000000..01840a1 --- /dev/null +++ b/features/common/src/androidMain/kotlin/dev/carlosmartino/common/Platform.android.kt @@ -0,0 +1,3 @@ +package dev.carlosmartino.common + +actual fun platform() = "Android" diff --git a/features/common/src/commonMain/kotlin/dev/carlosmartino/common/Platform.kt b/features/common/src/commonMain/kotlin/dev/carlosmartino/common/Platform.kt new file mode 100644 index 0000000..9ee9a40 --- /dev/null +++ b/features/common/src/commonMain/kotlin/dev/carlosmartino/common/Platform.kt @@ -0,0 +1,3 @@ +package dev.carlosmartino.common + +expect fun platform(): String diff --git a/features/common/src/iosMain/kotlin/dev/carlosmartino/common/Platform.ios.kt b/features/common/src/iosMain/kotlin/dev/carlosmartino/common/Platform.ios.kt new file mode 100644 index 0000000..1ea00f7 --- /dev/null +++ b/features/common/src/iosMain/kotlin/dev/carlosmartino/common/Platform.ios.kt @@ -0,0 +1,3 @@ +package dev.carlosmartino.common + +actual fun platform() = "iOS" diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 77536f1..7fe8ede 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -28,6 +28,8 @@ multiplatform-settings = "1.3.0" moko-permissions = "0.20.1" # Testing junit = "4.13.2" +runner = "1.5.2" +core = "1.5.0" [libraries] # Platform specific libraries @@ -43,6 +45,7 @@ kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serializa kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" } kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" } kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime"} +kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" } compose-multiplatform-navigation = { module = "org.jetbrains.androidx.navigation:navigation-compose", version.ref = "compose-multiplatform-navigation" } # Koin - Dependency Injection @@ -83,6 +86,8 @@ kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotl kotlin-testJunit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" } androidx-testExt-junit = { module = "androidx.test.ext:junit", version.ref = "androidx-testExt" } androidx-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "androidx-espresso" } +androidx-runner = { group = "androidx.test", name = "runner", version.ref = "runner" } +androidx-core = { group = "androidx.test", name = "core", version.ref = "core" } [plugins] androidApplication = { id = "com.android.application", version.ref = "agp" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 26782c3..b82ba5b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -33,3 +33,4 @@ include(":app:composeApp") include(":bedrock:designsystem") include(":bedrock:common") include(":bedrock:navigation") +include(":common")