diff --git a/aggregates/build.gradle.kts b/aggregates/build.gradle.kts new file mode 100644 index 0000000000..18a41032e6 --- /dev/null +++ b/aggregates/build.gradle.kts @@ -0,0 +1,52 @@ +plugins { + kotlin("multiplatform") + id("com.android.library") +} + +kotlin { + androidTarget { + compilations.all { + kotlinOptions { + jvmTarget = "1.8" + } + } + } + + jvm("desktop") + + listOf( + iosX64(), + iosArm64(), + iosSimulatorArm64() + ).forEach { + it.binaries.framework { + baseName = "aggregates" + isStatic = true + } + } + + sourceSets { + commonMain.dependencies { + //put your multiplatform dependencies here + } + commonTest.dependencies { + implementation(kotlin("test")) + } + + androidMain.dependencies { } + + androidUnitTest.dependencies { } + } +} + +android { + namespace = "org.dhis2.mobile.aggregates" + compileSdk = 34 + defaultConfig { + minSdk = 21 + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } +} diff --git a/aggregates/src/androidMain/kotlin/org/dhis2/mobile/aggregates/Platform.android.kt b/aggregates/src/androidMain/kotlin/org/dhis2/mobile/aggregates/Platform.android.kt new file mode 100644 index 0000000000..9d14d2af85 --- /dev/null +++ b/aggregates/src/androidMain/kotlin/org/dhis2/mobile/aggregates/Platform.android.kt @@ -0,0 +1,7 @@ +package org.dhis2.mobile.aggregates + +class AndroidPlatform : Platform { + override val name: String = "Android ${android.os.Build.VERSION.SDK_INT}" +} + +actual fun getPlatform(): Platform = AndroidPlatform() diff --git a/aggregates/src/androidUnitTest/kotlin/org/dhis2/mobile/aggregates/AndroidGreetingTest.kt b/aggregates/src/androidUnitTest/kotlin/org/dhis2/mobile/aggregates/AndroidGreetingTest.kt new file mode 100644 index 0000000000..6d512e6495 --- /dev/null +++ b/aggregates/src/androidUnitTest/kotlin/org/dhis2/mobile/aggregates/AndroidGreetingTest.kt @@ -0,0 +1,12 @@ +package org.dhis2.mobile.aggregates + +import org.junit.Assert.assertTrue +import org.junit.Test + +class AndroidGreetingTest { + + @Test + fun testExample() { + assertTrue("Check Android is mentioned", Greeting().greet().contains("Android")) + } +} diff --git a/aggregates/src/commonMain/kotlin/org/dhis2/mobile/aggregates/Greeting.kt b/aggregates/src/commonMain/kotlin/org/dhis2/mobile/aggregates/Greeting.kt new file mode 100644 index 0000000000..bb00b0000f --- /dev/null +++ b/aggregates/src/commonMain/kotlin/org/dhis2/mobile/aggregates/Greeting.kt @@ -0,0 +1,9 @@ +package org.dhis2.mobile.aggregates + +class Greeting { + private val platform: Platform = getPlatform() + + fun greet(): String { + return "Hello, ${platform.name}!" + } +} diff --git a/aggregates/src/commonMain/kotlin/org/dhis2/mobile/aggregates/Platform.kt b/aggregates/src/commonMain/kotlin/org/dhis2/mobile/aggregates/Platform.kt new file mode 100644 index 0000000000..496b981e1a --- /dev/null +++ b/aggregates/src/commonMain/kotlin/org/dhis2/mobile/aggregates/Platform.kt @@ -0,0 +1,7 @@ +package org.dhis2.mobile.aggregates + +interface Platform { + val name: String +} + +expect fun getPlatform(): Platform diff --git a/aggregates/src/commonTest/kotlin/org/dhis2/mobile/aggregates/CommonGreetingTest.kt b/aggregates/src/commonTest/kotlin/org/dhis2/mobile/aggregates/CommonGreetingTest.kt new file mode 100644 index 0000000000..cc11e9cad4 --- /dev/null +++ b/aggregates/src/commonTest/kotlin/org/dhis2/mobile/aggregates/CommonGreetingTest.kt @@ -0,0 +1,12 @@ +package org.dhis2.mobile.aggregates + +import kotlin.test.Test +import kotlin.test.assertTrue + +class CommonGreetingTest { + + @Test + fun testExample() { + assertTrue(Greeting().greet().contains("Hello"), "Check 'Hello' is mentioned") + } +} diff --git a/aggregates/src/iosMain/kotlin/org/dhis2/mobile/aggregates/Platform.ios.kt b/aggregates/src/iosMain/kotlin/org/dhis2/mobile/aggregates/Platform.ios.kt new file mode 100644 index 0000000000..a95fe67802 --- /dev/null +++ b/aggregates/src/iosMain/kotlin/org/dhis2/mobile/aggregates/Platform.ios.kt @@ -0,0 +1,9 @@ +package org.dhis2.mobile.aggregates + +import platform.UIKit.UIDevice + +class IOSPlatform : Platform { + override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion +} + +actual fun getPlatform(): Platform = IOSPlatform() diff --git a/aggregates/src/iosTest/kotlin/org/dhis2/mobile/aggregates/IosGreetingTest.kt b/aggregates/src/iosTest/kotlin/org/dhis2/mobile/aggregates/IosGreetingTest.kt new file mode 100644 index 0000000000..1bcc5d2cdd --- /dev/null +++ b/aggregates/src/iosTest/kotlin/org/dhis2/mobile/aggregates/IosGreetingTest.kt @@ -0,0 +1,12 @@ +package org.dhis2.mobile.aggregates + +import kotlin.test.Test +import kotlin.test.assertTrue + +class IosGreetingTest { + + @Test + fun testExample() { + assertTrue(Greeting().greet().contains("iOS"), "Check iOS is mentioned") + } +} diff --git a/app/build.gradle.kts b/app/build.gradle.kts index de5b427240..5fd0dedc75 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -252,6 +252,7 @@ dependencies { implementation(project(":stock-usecase")) implementation(project(":dhis2-mobile-program-rules")) implementation(project(":tracker")) + implementation(project(":aggregates")) implementation(libs.security.conscrypt) implementation(libs.security.rootbeer) diff --git a/settings.gradle.kts b/settings.gradle.kts index 4e90978fba..b24632a7f0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -6,3 +6,5 @@ include( ) include(":dhis2-mobile-program-rules") include(":tracker") +include(":aggregates") +//project(":aggregates").projectDir = file("/aggregates") diff --git a/stock-usecase/build.gradle.kts b/stock-usecase/build.gradle.kts index b04f1fb396..3997b319a0 100644 --- a/stock-usecase/build.gradle.kts +++ b/stock-usecase/build.gradle.kts @@ -92,6 +92,7 @@ dependencies { implementation(project(":dhis_android_analytics")) implementation(libs.bundles.stock.implementation) + implementation(project(":aggregates")) testImplementation(project(":dhis_android_analytics")) coreLibraryDesugaring(libs.bundles.stock.core) kapt(libs.bundles.stock.kapt)