From bddfe06c8a53731c9d908fa60b7cae1416e8c1ed Mon Sep 17 00:00:00 2001 From: Angelos Veglektsis Date: Tue, 18 Jun 2024 12:22:49 +0300 Subject: [PATCH] Enable Atomicfu transformations Add Android Instrumented Tests --- .../bindings-kotlin-multiplatform/.gitignore | 2 ++ .../breez-sdk-kmp/build.gradle.kts | 13 ++++++++++--- .../kotlin/InstrumentedTest.kt | 18 ++++++++++++++++++ .../gradle.properties | 6 ++++++ .../gradle/libs.versions.toml | 8 +++++++- 5 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 libs/sdk-bindings/bindings-kotlin-multiplatform/breez-sdk-kmp/src/androidInstrumentedTest/kotlin/InstrumentedTest.kt diff --git a/libs/sdk-bindings/bindings-kotlin-multiplatform/.gitignore b/libs/sdk-bindings/bindings-kotlin-multiplatform/.gitignore index 7a883e16b..76515edc2 100644 --- a/libs/sdk-bindings/bindings-kotlin-multiplatform/.gitignore +++ b/libs/sdk-bindings/bindings-kotlin-multiplatform/.gitignore @@ -44,6 +44,8 @@ gen-external-apklibs # End of https://www.toptal.com/developers/gitignore/api/android +.kotlin/ + breez-sdk-kmp/src/androiddMain/jniLibs/ breez-sdk-kmp/src/jvmMain/jniLibs/ diff --git a/libs/sdk-bindings/bindings-kotlin-multiplatform/breez-sdk-kmp/build.gradle.kts b/libs/sdk-bindings/bindings-kotlin-multiplatform/breez-sdk-kmp/build.gradle.kts index 0c51ac74d..421cb571c 100644 --- a/libs/sdk-bindings/bindings-kotlin-multiplatform/breez-sdk-kmp/build.gradle.kts +++ b/libs/sdk-bindings/bindings-kotlin-multiplatform/breez-sdk-kmp/build.gradle.kts @@ -67,17 +67,21 @@ kotlin { } val jvmMain by getting { - dependsOn(commonMain) dependencies { implementation(libs.jna) } } val androidMain by getting { - dependsOn(commonMain) dependencies { implementation("${libs.jna.get()}@aar") - implementation(libs.atomicfu) + } + } + + val androidInstrumentedTest by getting { + dependencies { + implementation(libs.test.junit.ktx) + implementation(libs.test.runner) } } } @@ -90,6 +94,9 @@ android { defaultConfig { minSdk = 21 consumerProguardFiles("consumer-rules.pro") + + testApplicationId = "technology.breez.test" + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } compileOptions { diff --git a/libs/sdk-bindings/bindings-kotlin-multiplatform/breez-sdk-kmp/src/androidInstrumentedTest/kotlin/InstrumentedTest.kt b/libs/sdk-bindings/bindings-kotlin-multiplatform/breez-sdk-kmp/src/androidInstrumentedTest/kotlin/InstrumentedTest.kt new file mode 100644 index 000000000..5a3e8ba17 --- /dev/null +++ b/libs/sdk-bindings/bindings-kotlin-multiplatform/breez-sdk-kmp/src/androidInstrumentedTest/kotlin/InstrumentedTest.kt @@ -0,0 +1,18 @@ +import androidx.test.ext.junit.runners.AndroidJUnit4 +import breez_sdk.LogEntry +import breez_sdk.LogStream +import breez_sdk.setLogStream +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +class InstrumentedTest { + @Test + fun simpleTest() { + setLogStream(object : LogStream { + override fun log(l: LogEntry) { + println(l.line) + } + }) + } +} \ No newline at end of file diff --git a/libs/sdk-bindings/bindings-kotlin-multiplatform/gradle.properties b/libs/sdk-bindings/bindings-kotlin-multiplatform/gradle.properties index eb592db4e..71af5d03e 100644 --- a/libs/sdk-bindings/bindings-kotlin-multiplatform/gradle.properties +++ b/libs/sdk-bindings/bindings-kotlin-multiplatform/gradle.properties @@ -8,6 +8,12 @@ kotlin.code.style=official android.useAndroidX=true android.nonTransitiveRClass=true +#Atomicfu +# for JVM IR transformation +kotlinx.atomicfu.enableJvmIrTransformation=true +# for Native IR transformation +kotlinx.atomicfu.enableNativeIrTransformation=true + #MPP kotlin.mpp.enableCInteropCommonization=true kotlin.mpp.androidSourceSetLayoutVersion=2 diff --git a/libs/sdk-bindings/bindings-kotlin-multiplatform/gradle/libs.versions.toml b/libs/sdk-bindings/bindings-kotlin-multiplatform/gradle/libs.versions.toml index 6a54c5095..87c4011aa 100644 --- a/libs/sdk-bindings/bindings-kotlin-multiplatform/gradle/libs.versions.toml +++ b/libs/sdk-bindings/bindings-kotlin-multiplatform/gradle/libs.versions.toml @@ -1,18 +1,24 @@ [versions] atomicfu = "0.24.0" -android-gradle-plugin = "8.4.1" +android-gradle-plugin = "8.4.2" jna = "5.14.0" +junit = "1.1.5" kotlin = "1.9.24" kotlinx-datetime = "0.6.0" okio = "3.9.0" +test-junit-ktx = "1.1.5" +test-runner = "1.5.2" [libraries] atomicfu = { module = "org.jetbrains.kotlinx:atomicfu-gradle-plugin", version.ref = "atomicfu" } android-gradle-plugin = { module = "com.android.tools.build:gradle", version.ref = "android-gradle-plugin" } +ext-junit = { module = "androidx.test.ext:junit", version.ref = "junit" } jna = { module = "net.java.dev.jna:jna", version.ref = "jna" } kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" } okio = { module = "com.squareup.okio:okio", version.ref = "okio" } +test-junit-ktx = { group = "androidx.test.ext", name = "junit-ktx", version.ref = "test-junit-ktx" } +test-runner = { module = "androidx.test:runner", version.ref = "test-runner" } [plugins] androidLibrary = { id = "com.android.library", version.ref = "android-gradle-plugin" }