diff --git a/couchbase-lite-ee-ktx/build.gradle.kts b/couchbase-lite-ee-ktx/build.gradle.kts index 29ad5d87b..9b0395eec 100644 --- a/couchbase-lite-ee-ktx/build.gradle.kts +++ b/couchbase-lite-ee-ktx/build.gradle.kts @@ -42,13 +42,6 @@ kotlin { macosX64() macosArm64() linuxX64() - // TODO: kotlinx atomicfu, datetime, and coroutines don't support arm64 or armhf - // https://github.com/Kotlin/kotlinx.atomicfu/pull/193 - // https://github.com/Kotlin/kotlinx-datetime/issues/75 - // https://github.com/Kotlin/kotlinx.coroutines/issues/855 - // https://github.com/square/okio/issues/1006 - //linuxArm64() - //linuxArm32Hfp() mingwX64() cocoapods { @@ -65,11 +58,7 @@ kotlin { } pod("CouchbaseLite-Enterprise") { version = libs.versions.couchbase.lite.objc.get() - moduleName = "CouchbaseLite" - packageName = "cocoapods.CouchbaseLite" - // Workaround for 'CBLQueryMeta' is going to be declared twice - // https://youtrack.jetbrains.com/issue/KT-41709 - extraOpts = listOf("-compiler-option", "-DCBLQueryMeta=CBLQueryMetaUnavailable") + linkOnly = true } } @@ -98,30 +87,12 @@ kotlin { } val commonTest by getting { dependencies { - implementation(libs.kotlin.test) - } - } - - val jvmIosCommonMain by creating { - dependsOn(commonMain) - dependencies { - compileOnly(libs.paging) - } - } - val jvmIosCommonTest by creating { - dependsOn(commonTest) - dependencies { - implementation(libs.kotlinx.coroutines.test) - implementation(libs.paging) - implementation(libs.kotlinx.atomicfu) + implementation(projects.testingSupportEe) } } val jvmCommonTest by creating { - dependsOn(jvmIosCommonTest) - } - val jvmMain by getting { - dependsOn(jvmIosCommonMain) + dependsOn(commonTest) } val jvmTest by getting { dependsOn(jvmCommonTest) @@ -130,16 +101,13 @@ kotlin { } } val androidMain by getting { - dependsOn(jvmIosCommonMain) dependencies { compileOnly(libs.androidx.lifecycle.runtime.ktx) } } val androidInstrumentedTest by getting { dependsOn(jvmCommonTest) - dependsOn(jvmIosCommonTest) dependencies { - implementation(libs.androidx.test.core.ktx) implementation(libs.androidx.test.runner) implementation(libs.mockk.android) } @@ -153,15 +121,9 @@ kotlin { dependsOn(nativeCommonTest) } - val iosMain by getting { - dependsOn(jvmIosCommonMain) - dependencies { - implementation(libs.paging) - } - } + val iosMain by getting val iosTest by getting { dependsOn(appleTest) - dependsOn(jvmIosCommonTest) } val iosSimulatorArm64Main by getting { dependsOn(iosMain) @@ -183,16 +145,6 @@ kotlin { val linuxX64Test by getting { dependsOn(nativeTest) } - // TODO: use linux arm builds from https://github.com/danbrough/kotlinxtras/ - //val linuxArm64Main by getting { - // dependsOn(nativeTest) - //} - //val linuxArm64Test by getting { - // dependsOn(nativeTest) - //} - //val linuxArm32HfpTest by getting { - // dependsOn(nativeTest) - //} val mingwX64Test by getting { dependsOn(nativeTest) } diff --git a/couchbase-lite-ee-paging/CouchbaseLite-Enterprise-KMP-Paging.podspec b/couchbase-lite-ee-paging/CouchbaseLite-Enterprise-KMP-Paging.podspec new file mode 100644 index 000000000..b89a4cbe0 --- /dev/null +++ b/couchbase-lite-ee-paging/CouchbaseLite-Enterprise-KMP-Paging.podspec @@ -0,0 +1,39 @@ +Pod::Spec.new do |spec| + spec.name = 'CouchbaseLite-Enterprise-KMP-Paging' + spec.version = '3.0.5-1-SNAPSHOT' + spec.homepage = 'https://github.com/udobny/couchbase-lite-kmp' + spec.source = { :http=> ''} + spec.authors = 'Couchbase, Jeff Lockhart' + spec.license = 'Custom, Apache License, Version 2.0' + spec.summary = 'Couchbase Lite Enterprise Edition for Kotlin Multiplatform AndroidX Paging Extensions' + spec.vendored_frameworks = 'build/cocoapods/framework/CouchbaseLite_Enterprise_KMP_Paging.framework' + spec.libraries = 'c++' + spec.ios.deployment_target = '9.0' + spec.dependency 'CouchbaseLite-Enterprise', '3.0.2' + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':couchbase-lite-ee-paging', + 'PRODUCT_MODULE_NAME' => 'CouchbaseLite_Enterprise_KMP_Paging', + } + + spec.script_phases = [ + { + :name => 'Build CouchbaseLite-Enterprise-KMP-Paging', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end \ No newline at end of file diff --git a/couchbase-lite-ee-paging/build.gradle.kts b/couchbase-lite-ee-paging/build.gradle.kts new file mode 100644 index 000000000..a92a6a3bf --- /dev/null +++ b/couchbase-lite-ee-paging/build.gradle.kts @@ -0,0 +1,114 @@ +@file:Suppress("UNUSED_VARIABLE") + +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi +import org.jetbrains.kotlin.gradle.plugin.KotlinTargetHierarchy.SourceSetTree +import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest + +plugins { + kotlin("multiplatform") + kotlin("native.cocoapods") + id("com.android.library") + id("org.jetbrains.dokka") + id("maven-publish") +} + +repositories { + maven("https://mobile.maven.couchbase.com/maven2/dev/") +} + +kotlin { + explicitApiWarning() + + jvmToolchain(8) + + androidTarget { + publishLibraryVariants("release") + } + @OptIn(ExperimentalKotlinGradlePluginApi::class) + targetHierarchy.android { + instrumentedTest.sourceSetTree.set(SourceSetTree.test) + unitTest.sourceSetTree.set(SourceSetTree.unitTest) + } + + jvm() + ios() + iosSimulatorArm64() + + cocoapods { + name = "CouchbaseLite-Enterprise-KMP-Paging" + homepage = "https://github.com/udobny/couchbase-lite-kmp" + authors = "Couchbase, Jeff Lockhart" + license = "Custom, Apache License, Version 2.0" + summary = "Couchbase Lite Enterprise Edition for Kotlin Multiplatform AndroidX Paging Extensions" + ios.deploymentTarget = "9.0" + framework { + baseName = this@cocoapods.name.replace('-', '_') + isStatic = false + } + pod("CouchbaseLite-Enterprise") { + version = libs.versions.couchbase.lite.objc.get() + linkOnly = true + } + } + + sourceSets { + val commonMain by getting { + dependencies { + api(projects.couchbaseLiteEeKtx) + api(libs.paging) + } + } + val commonTest by getting { + dependencies { + implementation(projects.testingSupportEe) + implementation(libs.kotlinx.coroutines.test) + implementation(libs.kotlinx.atomicfu) + } + } + val iosMain by getting + val iosTest by getting + val iosSimulatorArm64Main by getting { + dependsOn(iosMain) + } + val iosSimulatorArm64Test by getting { + dependsOn(iosTest) + } + } +} + +android { + namespace = "com.udobny.kmp.couchbase.lite.paging" + compileSdk = 33 + defaultConfig { + minSdk = 22 + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + // required until AGP 8.1.0-alpha09+ + // https://kotlinlang.org/docs/gradle-configure-project.html#gradle-java-toolchains-support + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } +} + +// Documentation Jar + +val dokkaOutputDir = buildDir.resolve("dokka") + +tasks.dokkaHtml.configure { + outputDirectory.set(dokkaOutputDir) +} + +val javadocJar = tasks.register("javadocJar") { + dependsOn(tasks.dokkaHtml) + archiveClassifier.set("javadoc") + from(dokkaOutputDir) +} + +publishing.publications.withType { + artifact(javadocJar) +} + +tasks.withType { + device.set("iPhone 14") +} diff --git a/couchbase-lite-ee-paging/src b/couchbase-lite-ee-paging/src new file mode 120000 index 000000000..42fe2ef31 --- /dev/null +++ b/couchbase-lite-ee-paging/src @@ -0,0 +1 @@ +../couchbase-lite-paging/src \ No newline at end of file diff --git a/couchbase-lite-ktx/build.gradle.kts b/couchbase-lite-ktx/build.gradle.kts index 6fca4ac1f..1558700fd 100644 --- a/couchbase-lite-ktx/build.gradle.kts +++ b/couchbase-lite-ktx/build.gradle.kts @@ -38,13 +38,6 @@ kotlin { macosX64() macosArm64() linuxX64() - // TODO: kotlinx atomicfu, datetime, and coroutines don't support arm64 or armhf - // https://github.com/Kotlin/kotlinx.atomicfu/pull/193 - // https://github.com/Kotlin/kotlinx-datetime/issues/75 - // https://github.com/Kotlin/kotlinx.coroutines/issues/855 - // https://github.com/square/okio/issues/1006 - //linuxArm64() - //linuxArm32Hfp() mingwX64() cocoapods { @@ -63,9 +56,7 @@ kotlin { version = libs.versions.couchbase.lite.objc.get() // use local build //source = path("$rootDir/../couchbase-lite-ios") - // Workaround for 'CBLQueryMeta' is going to be declared twice - // https://youtrack.jetbrains.com/issue/KT-41709 - extraOpts = listOf("-compiler-option", "-DCBLQueryMeta=CBLQueryMetaUnavailable") + linkOnly = true } } @@ -94,30 +85,12 @@ kotlin { } val commonTest by getting { dependencies { - implementation(libs.kotlin.test) - } - } - - val jvmIosCommonMain by creating { - dependsOn(commonMain) - dependencies { - compileOnly(libs.paging) - } - } - val jvmIosCommonTest by creating { - dependsOn(commonTest) - dependencies { - implementation(libs.kotlinx.coroutines.test) - implementation(libs.paging) - implementation(libs.kotlinx.atomicfu) + implementation(projects.testingSupport) } } val jvmCommonTest by creating { - dependsOn(jvmIosCommonTest) - } - val jvmMain by getting { - dependsOn(jvmIosCommonMain) + dependsOn(commonTest) } val jvmTest by getting { dependsOn(jvmCommonTest) @@ -126,16 +99,13 @@ kotlin { } } val androidMain by getting { - dependsOn(jvmIosCommonMain) dependencies { compileOnly(libs.androidx.lifecycle.runtime.ktx) } } val androidInstrumentedTest by getting { dependsOn(jvmCommonTest) - dependsOn(jvmIosCommonTest) dependencies { - implementation(libs.androidx.test.core.ktx) implementation(libs.androidx.test.runner) implementation(libs.mockk.android) } @@ -149,15 +119,9 @@ kotlin { dependsOn(nativeCommonTest) } - val iosMain by getting { - dependsOn(jvmIosCommonMain) - dependencies { - implementation(libs.paging) - } - } + val iosMain by getting val iosTest by getting { dependsOn(appleTest) - dependsOn(jvmIosCommonTest) } val iosSimulatorArm64Main by getting { dependsOn(iosMain) @@ -179,16 +143,6 @@ kotlin { val linuxX64Test by getting { dependsOn(nativeTest) } - // TODO: use linux arm builds from https://github.com/danbrough/kotlinxtras/ - //val linuxArm64Main by getting { - // dependsOn(nativeTest) - //} - //val linuxArm64Test by getting { - // dependsOn(nativeTest) - //} - //val linuxArm32HfpTest by getting { - // dependsOn(nativeTest) - //} val mingwX64Test by getting { dependsOn(nativeTest) } diff --git a/couchbase-lite-ktx/src/appleTest/kotlin/com/udobny/kmp/test/Annotations.kt b/couchbase-lite-ktx/src/appleTest/kotlin/com/udobny/kmp/test/Annotations.kt deleted file mode 100644 index ba0fc35f8..000000000 --- a/couchbase-lite-ktx/src/appleTest/kotlin/com/udobny/kmp/test/Annotations.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.udobny.kmp.test - -actual typealias IgnoreApple = kotlin.test.Ignore diff --git a/couchbase-lite-ktx/src/commonTest/kotlin/com/molo17/couchbase/lite/kmp/QueryBuilderExtensionsKtTest.kt b/couchbase-lite-ktx/src/commonTest/kotlin/com/molo17/couchbase/lite/kmp/QueryBuilderExtensionsKtTest.kt index 76481f4b5..bb6e6ebc6 100644 --- a/couchbase-lite-ktx/src/commonTest/kotlin/com/molo17/couchbase/lite/kmp/QueryBuilderExtensionsKtTest.kt +++ b/couchbase-lite-ktx/src/commonTest/kotlin/com/molo17/couchbase/lite/kmp/QueryBuilderExtensionsKtTest.kt @@ -28,7 +28,7 @@ import com.couchbase.lite.kmp.Expression import com.couchbase.lite.kmp.Ordering import com.couchbase.lite.kmp.QueryBuilder import com.couchbase.lite.kmp.SelectResult -import com.udobny.kmp.couchbase.lite.ktx.BaseTest +import com.udobny.kmp.couchbase.lite.BaseTest import kotlinx.datetime.Clock import kotlin.test.Test import kotlin.test.assertEquals diff --git a/couchbase-lite-ktx/src/commonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/PlatformUtils.kt b/couchbase-lite-ktx/src/commonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/PlatformUtils.kt deleted file mode 100644 index fcb65dba1..000000000 --- a/couchbase-lite-ktx/src/commonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/PlatformUtils.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.udobny.kmp.couchbase.lite.ktx - -expect fun initCouchbaseLite() diff --git a/couchbase-lite-ktx/src/commonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/QueryBuilderExtTest.kt b/couchbase-lite-ktx/src/commonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/QueryBuilderExtTest.kt index cb72cce0e..682cc2e9f 100644 --- a/couchbase-lite-ktx/src/commonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/QueryBuilderExtTest.kt +++ b/couchbase-lite-ktx/src/commonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/QueryBuilderExtTest.kt @@ -4,6 +4,7 @@ import com.couchbase.lite.kmp.* import com.couchbase.lite.kmp.Function import com.molo17.couchbase.lite.kmp.all import com.molo17.couchbase.lite.kmp.from +import com.udobny.kmp.couchbase.lite.BaseTest import kotlin.test.Test import kotlin.test.assertEquals diff --git a/couchbase-lite-ktx/src/commonTest/kotlin/com/udobny/kmp/test/Annotations.kt b/couchbase-lite-ktx/src/commonTest/kotlin/com/udobny/kmp/test/Annotations.kt deleted file mode 100644 index 272c78d94..000000000 --- a/couchbase-lite-ktx/src/commonTest/kotlin/com/udobny/kmp/test/Annotations.kt +++ /dev/null @@ -1,4 +0,0 @@ -package com.udobny.kmp.test - -@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) -expect annotation class IgnoreApple() diff --git a/couchbase-lite-ktx/src/jvmCommonTest/kotlin/com/udobny/kmp/test/Annotations.kt b/couchbase-lite-ktx/src/jvmCommonTest/kotlin/com/udobny/kmp/test/Annotations.kt deleted file mode 100644 index eb244087d..000000000 --- a/couchbase-lite-ktx/src/jvmCommonTest/kotlin/com/udobny/kmp/test/Annotations.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.udobny.kmp.test - -actual annotation class IgnoreApple diff --git a/couchbase-lite-ktx/src/nativeTest/kotlin/com/udobny/kmp/test/Annotations.kt b/couchbase-lite-ktx/src/nativeTest/kotlin/com/udobny/kmp/test/Annotations.kt deleted file mode 100644 index eb244087d..000000000 --- a/couchbase-lite-ktx/src/nativeTest/kotlin/com/udobny/kmp/test/Annotations.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.udobny.kmp.test - -actual annotation class IgnoreApple diff --git a/couchbase-lite-paging/Couchbase-Lite-KMP-Paging.podspec b/couchbase-lite-paging/Couchbase-Lite-KMP-Paging.podspec new file mode 100644 index 000000000..77b73dbd2 --- /dev/null +++ b/couchbase-lite-paging/Couchbase-Lite-KMP-Paging.podspec @@ -0,0 +1,39 @@ +Pod::Spec.new do |spec| + spec.name = 'Couchbase-Lite-KMP-Paging' + spec.version = '3.0.5-1-SNAPSHOT' + spec.homepage = 'https://github.com/udobny/couchbase-lite-kmp' + spec.source = { :http=> ''} + spec.authors = 'Jeff Lockhart' + spec.license = 'Apache License, Version 2.0' + spec.summary = 'Couchbase Lite for Kotlin Multiplatform AndroidX Paging Extensions' + spec.vendored_frameworks = 'build/cocoapods/framework/Couchbase_Lite_KMP_Paging.framework' + spec.libraries = 'c++' + spec.ios.deployment_target = '9.0' + spec.dependency 'CouchbaseLite', '3.0.2' + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':couchbase-lite-paging', + 'PRODUCT_MODULE_NAME' => 'Couchbase_Lite_KMP_Paging', + } + + spec.script_phases = [ + { + :name => 'Build Couchbase-Lite-KMP-Paging', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end \ No newline at end of file diff --git a/couchbase-lite-paging/build.gradle.kts b/couchbase-lite-paging/build.gradle.kts new file mode 100644 index 000000000..697a012d5 --- /dev/null +++ b/couchbase-lite-paging/build.gradle.kts @@ -0,0 +1,112 @@ +@file:Suppress("UNUSED_VARIABLE") + +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi +import org.jetbrains.kotlin.gradle.plugin.KotlinTargetHierarchy.SourceSetTree +import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest + +plugins { + kotlin("multiplatform") + kotlin("native.cocoapods") + id("com.android.library") + id("org.jetbrains.dokka") + id("maven-publish") +} + +kotlin { + explicitApiWarning() + + jvmToolchain(8) + + androidTarget { + publishLibraryVariants("release") + } + @OptIn(ExperimentalKotlinGradlePluginApi::class) + targetHierarchy.android { + instrumentedTest.sourceSetTree.set(SourceSetTree.test) + unitTest.sourceSetTree.set(SourceSetTree.unitTest) + } + + jvm() + ios() + iosSimulatorArm64() + + cocoapods { + name = "Couchbase-Lite-KMP-Paging" + homepage = "https://github.com/udobny/couchbase-lite-kmp" + authors = "Jeff Lockhart" + license = "Apache License, Version 2.0" + summary = "Couchbase Lite for Kotlin Multiplatform AndroidX Paging Extensions" + ios.deploymentTarget = "9.0" + framework { + baseName = this@cocoapods.name.replace('-', '_') + isStatic = false + } + pod("CouchbaseLite") { + version = libs.versions.couchbase.lite.objc.get() + // use local build + //source = path("$rootDir/../couchbase-lite-ios") + linkOnly = true + } + } + + sourceSets { + val commonMain by getting { + dependencies { + api(projects.couchbaseLiteKtx) + api(libs.paging) + } + } + val commonTest by getting { + dependencies { + implementation(projects.testingSupport) + implementation(libs.kotlinx.coroutines.test) + implementation(libs.kotlinx.atomicfu) + } + } + val iosMain by getting + val iosTest by getting + val iosSimulatorArm64Main by getting { + dependsOn(iosMain) + } + val iosSimulatorArm64Test by getting { + dependsOn(iosTest) + } + } +} + +android { + namespace = "com.udobny.kmp.couchbase.lite.paging" + compileSdk = 33 + defaultConfig { + minSdk = 22 + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + // required until AGP 8.1.0-alpha09+ + // https://kotlinlang.org/docs/gradle-configure-project.html#gradle-java-toolchains-support + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } +} + +// Documentation Jar + +val dokkaOutputDir = buildDir.resolve("dokka") + +tasks.dokkaHtml.configure { + outputDirectory.set(dokkaOutputDir) +} + +val javadocJar = tasks.register("javadocJar") { + dependsOn(tasks.dokkaHtml) + archiveClassifier.set("javadoc") + from(dokkaOutputDir) +} + +publishing.publications.withType { + artifact(javadocJar) +} + +tasks.withType { + device.set("iPhone 14") +} diff --git a/couchbase-lite-ktx/src/jvmIosCommonMain/kotlin/com/udobny/kmp/couchbase/lite/ktx/paging3/OffsetQueryPagingSource.kt b/couchbase-lite-paging/src/commonMain/kotlin/com/udobny/kmp/couchbase/lite/ktx/paging3/OffsetQueryPagingSource.kt similarity index 100% rename from couchbase-lite-ktx/src/jvmIosCommonMain/kotlin/com/udobny/kmp/couchbase/lite/ktx/paging3/OffsetQueryPagingSource.kt rename to couchbase-lite-paging/src/commonMain/kotlin/com/udobny/kmp/couchbase/lite/ktx/paging3/OffsetQueryPagingSource.kt diff --git a/couchbase-lite-ktx/src/jvmIosCommonMain/kotlin/com/udobny/kmp/couchbase/lite/ktx/paging3/QueryPagingSource.kt b/couchbase-lite-paging/src/commonMain/kotlin/com/udobny/kmp/couchbase/lite/ktx/paging3/QueryPagingSource.kt similarity index 100% rename from couchbase-lite-ktx/src/jvmIosCommonMain/kotlin/com/udobny/kmp/couchbase/lite/ktx/paging3/QueryPagingSource.kt rename to couchbase-lite-paging/src/commonMain/kotlin/com/udobny/kmp/couchbase/lite/ktx/paging3/QueryPagingSource.kt diff --git a/couchbase-lite-ktx/src/jvmIosCommonTest/kotlin/androidx/paging/AsyncPagingDataDiffer.kt b/couchbase-lite-paging/src/commonTest/kotlin/androidx/paging/AsyncPagingDataDiffer.kt similarity index 100% rename from couchbase-lite-ktx/src/jvmIosCommonTest/kotlin/androidx/paging/AsyncPagingDataDiffer.kt rename to couchbase-lite-paging/src/commonTest/kotlin/androidx/paging/AsyncPagingDataDiffer.kt diff --git a/couchbase-lite-ktx/src/jvmIosCommonTest/kotlin/androidx/paging/NullPaddedListDiffHelper.kt b/couchbase-lite-paging/src/commonTest/kotlin/androidx/paging/NullPaddedListDiffHelper.kt similarity index 100% rename from couchbase-lite-ktx/src/jvmIosCommonTest/kotlin/androidx/paging/NullPaddedListDiffHelper.kt rename to couchbase-lite-paging/src/commonTest/kotlin/androidx/paging/NullPaddedListDiffHelper.kt diff --git a/couchbase-lite-ktx/src/jvmIosCommonTest/kotlin/androidx/recyclerview/widget/BatchingListUpdateCallback.kt b/couchbase-lite-paging/src/commonTest/kotlin/androidx/recyclerview/widget/BatchingListUpdateCallback.kt similarity index 100% rename from couchbase-lite-ktx/src/jvmIosCommonTest/kotlin/androidx/recyclerview/widget/BatchingListUpdateCallback.kt rename to couchbase-lite-paging/src/commonTest/kotlin/androidx/recyclerview/widget/BatchingListUpdateCallback.kt diff --git a/couchbase-lite-ktx/src/jvmIosCommonTest/kotlin/androidx/recyclerview/widget/DiffUtil.kt b/couchbase-lite-paging/src/commonTest/kotlin/androidx/recyclerview/widget/DiffUtil.kt similarity index 100% rename from couchbase-lite-ktx/src/jvmIosCommonTest/kotlin/androidx/recyclerview/widget/DiffUtil.kt rename to couchbase-lite-paging/src/commonTest/kotlin/androidx/recyclerview/widget/DiffUtil.kt diff --git a/couchbase-lite-ktx/src/jvmIosCommonTest/kotlin/androidx/recyclerview/widget/ListUpdateCallback.kt b/couchbase-lite-paging/src/commonTest/kotlin/androidx/recyclerview/widget/ListUpdateCallback.kt similarity index 100% rename from couchbase-lite-ktx/src/jvmIosCommonTest/kotlin/androidx/recyclerview/widget/ListUpdateCallback.kt rename to couchbase-lite-paging/src/commonTest/kotlin/androidx/recyclerview/widget/ListUpdateCallback.kt diff --git a/couchbase-lite-ktx/src/jvmIosCommonTest/kotlin/androidx/recyclerview/widget/RecyclerView.kt b/couchbase-lite-paging/src/commonTest/kotlin/androidx/recyclerview/widget/RecyclerView.kt similarity index 100% rename from couchbase-lite-ktx/src/jvmIosCommonTest/kotlin/androidx/recyclerview/widget/RecyclerView.kt rename to couchbase-lite-paging/src/commonTest/kotlin/androidx/recyclerview/widget/RecyclerView.kt diff --git a/couchbase-lite-ktx/src/jvmIosCommonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/paging3/OffsetQueryPagingSourceTest.kt b/couchbase-lite-paging/src/commonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/paging3/OffsetQueryPagingSourceTest.kt similarity index 99% rename from couchbase-lite-ktx/src/jvmIosCommonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/paging3/OffsetQueryPagingSourceTest.kt rename to couchbase-lite-paging/src/commonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/paging3/OffsetQueryPagingSourceTest.kt index 050d5ed52..779b19a73 100644 --- a/couchbase-lite-ktx/src/jvmIosCommonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/paging3/OffsetQueryPagingSourceTest.kt +++ b/couchbase-lite-paging/src/commonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/paging3/OffsetQueryPagingSourceTest.kt @@ -31,7 +31,7 @@ import com.couchbase.lite.kmp.MutableDocument import com.couchbase.lite.kmp.Query import com.molo17.couchbase.lite.kmp.from import com.molo17.couchbase.lite.kmp.limit -import com.udobny.kmp.couchbase.lite.ktx.BaseTest +import com.udobny.kmp.couchbase.lite.BaseTest import com.udobny.kmp.couchbase.lite.ktx.select import com.udobny.kmp.couchbase.lite.ktx.selectCount import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/couchbase-lite-ktx/src/jvmIosCommonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/paging3/WithPagingDataDiffer.kt b/couchbase-lite-paging/src/commonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/paging3/WithPagingDataDiffer.kt similarity index 100% rename from couchbase-lite-ktx/src/jvmIosCommonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/paging3/WithPagingDataDiffer.kt rename to couchbase-lite-paging/src/commonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/paging3/WithPagingDataDiffer.kt diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d921cb3d0..cac2727a1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -16,6 +16,7 @@ couchbase-lite-java-ee = { module = "com.couchbase.lite:couchbase-lite-java-ee", junit = { module = "junit:junit", version = "4.13.2" } korlibs-korio = { module = "com.soywiz.korlibs.korio:korio", version = "4.0.0-rc5" } kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test" } +kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit" } kotlinx-atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version = "0.20.2" } kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" } kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" } diff --git a/settings.gradle.kts b/settings.gradle.kts index f3cc69e3d..60a5f8f80 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -8,10 +8,10 @@ pluginManagement { } rootProject.name = "couchbase-lite-kmp" -include(":couchbase-lite") -include(":couchbase-lite-ktx") -include(":couchbase-lite-ee") -include(":couchbase-lite-ee-ktx") +include(":couchbase-lite", ":couchbase-lite-ee") +include(":couchbase-lite-ktx", ":couchbase-lite-ee-ktx") +include(":couchbase-lite-paging", ":couchbase-lite-ee-paging") +include(":testing-support", ":testing-support-ee") // Add gradle module metadata to differentiate between Couchbase Lite Java and Android variants // Fixes false positive error in IDE in CouchbaseLite.init() in androidMain diff --git a/testing-support-ee/build.gradle.kts b/testing-support-ee/build.gradle.kts new file mode 100644 index 000000000..83ff30c64 --- /dev/null +++ b/testing-support-ee/build.gradle.kts @@ -0,0 +1,87 @@ +@file:Suppress("UNUSED_VARIABLE") + +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi +import org.jetbrains.kotlin.gradle.plugin.KotlinTargetHierarchy.SourceSetTree +import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest + +plugins { + kotlin("multiplatform") + kotlin("native.cocoapods") + id("com.android.library") +} + +repositories { + maven("https://mobile.maven.couchbase.com/maven2/dev/") +} + +kotlin { + jvmToolchain(8) + + androidTarget { + publishLibraryVariants("release") + } + @OptIn(ExperimentalKotlinGradlePluginApi::class) + targetHierarchy.android { + instrumentedTest.sourceSetTree.set(SourceSetTree.test) + unitTest.sourceSetTree.set(SourceSetTree.unitTest) + } + + jvm() + ios() + iosSimulatorArm64() + macosX64() + macosArm64() + linuxX64() + mingwX64() + + sourceSets { + val commonMain by getting { + dependencies { + api(projects.couchbaseLiteEe) + api(libs.kotlin.test) + api(libs.kotlin.test.junit) + } + } + val androidMain by getting { + dependencies { + api(libs.androidx.test.core.ktx) + } + } + val nativeMain by creating { + dependsOn(commonMain) + } + val iosMain by getting { + dependsOn(nativeMain) + } + val iosSimulatorArm64Main by getting { + dependsOn(iosMain) + } + val macosX64Main by getting { + dependsOn(nativeMain) + } + val macosArm64Main by getting { + dependsOn(nativeMain) + } + val linuxX64Main by getting { + dependsOn(nativeMain) + } + val mingwX64Main by getting { + dependsOn(nativeMain) + } + } +} + +android { + namespace = "com.udobny.kmp.couchbase.lite.testingsupport" + compileSdk = 33 + defaultConfig { + minSdk = 22 + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + // required until AGP 8.1.0-alpha09+ + // https://kotlinlang.org/docs/gradle-configure-project.html#gradle-java-toolchains-support + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } +} diff --git a/testing-support-ee/src b/testing-support-ee/src new file mode 120000 index 000000000..be07df984 --- /dev/null +++ b/testing-support-ee/src @@ -0,0 +1 @@ +../testing-support/src \ No newline at end of file diff --git a/testing-support-ee/testing_support_ee.podspec b/testing-support-ee/testing_support_ee.podspec new file mode 100644 index 000000000..442823a25 --- /dev/null +++ b/testing-support-ee/testing_support_ee.podspec @@ -0,0 +1,39 @@ +Pod::Spec.new do |spec| + spec.name = 'testing_support_ee' + spec.version = '3.0.5-1-SNAPSHOT' + spec.homepage = '' + spec.source = { :http=> ''} + spec.authors = '' + spec.license = '' + spec.summary = '' + spec.vendored_frameworks = 'build/cocoapods/framework/testing_support_ee.framework' + spec.libraries = 'c++' + + + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':testing-support-ee', + 'PRODUCT_MODULE_NAME' => 'testing_support_ee', + } + + spec.script_phases = [ + { + :name => 'Build testing_support_ee', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end \ No newline at end of file diff --git a/testing-support/build.gradle.kts b/testing-support/build.gradle.kts new file mode 100644 index 000000000..7d31db560 --- /dev/null +++ b/testing-support/build.gradle.kts @@ -0,0 +1,83 @@ +@file:Suppress("UNUSED_VARIABLE") + +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi +import org.jetbrains.kotlin.gradle.plugin.KotlinTargetHierarchy.SourceSetTree +import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest + +plugins { + kotlin("multiplatform") + kotlin("native.cocoapods") + id("com.android.library") +} + +kotlin { + jvmToolchain(8) + + androidTarget { + publishLibraryVariants("release") + } + @OptIn(ExperimentalKotlinGradlePluginApi::class) + targetHierarchy.android { + instrumentedTest.sourceSetTree.set(SourceSetTree.test) + unitTest.sourceSetTree.set(SourceSetTree.unitTest) + } + + jvm() + ios() + iosSimulatorArm64() + macosX64() + macosArm64() + linuxX64() + mingwX64() + + sourceSets { + val commonMain by getting { + dependencies { + api(projects.couchbaseLite) + api(libs.kotlin.test) + api(libs.kotlin.test.junit) + } + } + val androidMain by getting { + dependencies { + api(libs.androidx.test.core.ktx) + } + } + val nativeMain by creating { + dependsOn(commonMain) + } + val iosMain by getting { + dependsOn(nativeMain) + } + val iosSimulatorArm64Main by getting { + dependsOn(iosMain) + } + val macosX64Main by getting { + dependsOn(nativeMain) + } + val macosArm64Main by getting { + dependsOn(nativeMain) + } + val linuxX64Main by getting { + dependsOn(nativeMain) + } + val mingwX64Main by getting { + dependsOn(nativeMain) + } + } +} + +android { + namespace = "com.udobny.kmp.couchbase.lite.testingsupport" + compileSdk = 33 + defaultConfig { + minSdk = 22 + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + // required until AGP 8.1.0-alpha09+ + // https://kotlinlang.org/docs/gradle-configure-project.html#gradle-java-toolchains-support + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } +} diff --git a/couchbase-lite-ktx/src/androidInstrumentedTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/PlatformUtils.kt b/testing-support/src/androidMain/kotlin/com/udobny/kmp/couchbase/lite/PlatformUtils.kt similarity index 83% rename from couchbase-lite-ktx/src/androidInstrumentedTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/PlatformUtils.kt rename to testing-support/src/androidMain/kotlin/com/udobny/kmp/couchbase/lite/PlatformUtils.kt index 9f337a1a5..abf962ca9 100644 --- a/couchbase-lite-ktx/src/androidInstrumentedTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/PlatformUtils.kt +++ b/testing-support/src/androidMain/kotlin/com/udobny/kmp/couchbase/lite/PlatformUtils.kt @@ -1,4 +1,4 @@ -package com.udobny.kmp.couchbase.lite.ktx +package com.udobny.kmp.couchbase.lite import androidx.test.core.app.ApplicationProvider.getApplicationContext import com.couchbase.lite.kmp.CouchbaseLite diff --git a/couchbase-lite-ktx/src/commonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/BaseTest.kt b/testing-support/src/commonMain/kotlin/com/udobny/kmp/couchbase/lite/BaseTest.kt similarity index 96% rename from couchbase-lite-ktx/src/commonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/BaseTest.kt rename to testing-support/src/commonMain/kotlin/com/udobny/kmp/couchbase/lite/BaseTest.kt index 9ea2f1413..15ae3ca8e 100644 --- a/couchbase-lite-ktx/src/commonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/BaseTest.kt +++ b/testing-support/src/commonMain/kotlin/com/udobny/kmp/couchbase/lite/BaseTest.kt @@ -1,4 +1,4 @@ -package com.udobny.kmp.couchbase.lite.ktx +package com.udobny.kmp.couchbase.lite import com.couchbase.lite.kmp.Database import com.couchbase.lite.kmp.DatabaseConfiguration diff --git a/testing-support/src/commonMain/kotlin/com/udobny/kmp/couchbase/lite/PlatformUtils.kt b/testing-support/src/commonMain/kotlin/com/udobny/kmp/couchbase/lite/PlatformUtils.kt new file mode 100644 index 000000000..ae7caf2e9 --- /dev/null +++ b/testing-support/src/commonMain/kotlin/com/udobny/kmp/couchbase/lite/PlatformUtils.kt @@ -0,0 +1,3 @@ +package com.udobny.kmp.couchbase.lite + +expect fun initCouchbaseLite() diff --git a/couchbase-lite-ktx/src/jvmTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/PlatformUtils.kt b/testing-support/src/jvmMain/kotlin/com/udobny/kmp/couchbase/lite/PlatformUtils.kt similarity index 81% rename from couchbase-lite-ktx/src/jvmTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/PlatformUtils.kt rename to testing-support/src/jvmMain/kotlin/com/udobny/kmp/couchbase/lite/PlatformUtils.kt index 0b5a9def4..4b1d964f8 100644 --- a/couchbase-lite-ktx/src/jvmTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/PlatformUtils.kt +++ b/testing-support/src/jvmMain/kotlin/com/udobny/kmp/couchbase/lite/PlatformUtils.kt @@ -1,4 +1,4 @@ -package com.udobny.kmp.couchbase.lite.ktx +package com.udobny.kmp.couchbase.lite import com.couchbase.lite.kmp.CouchbaseLite import java.io.File diff --git a/couchbase-lite-ktx/src/nativeCommonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/PlatformUtils.kt b/testing-support/src/nativeMain/kotlin/com/udobny/kmp/couchbase/lite/PlatformUtils.kt similarity index 53% rename from couchbase-lite-ktx/src/nativeCommonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/PlatformUtils.kt rename to testing-support/src/nativeMain/kotlin/com/udobny/kmp/couchbase/lite/PlatformUtils.kt index 6b3c92c78..6c409b464 100644 --- a/couchbase-lite-ktx/src/nativeCommonTest/kotlin/com/udobny/kmp/couchbase/lite/ktx/PlatformUtils.kt +++ b/testing-support/src/nativeMain/kotlin/com/udobny/kmp/couchbase/lite/PlatformUtils.kt @@ -1,4 +1,4 @@ -package com.udobny.kmp.couchbase.lite.ktx +package com.udobny.kmp.couchbase.lite actual fun initCouchbaseLite() { // no-op diff --git a/testing-support/testing_support.podspec b/testing-support/testing_support.podspec new file mode 100644 index 000000000..672d97b08 --- /dev/null +++ b/testing-support/testing_support.podspec @@ -0,0 +1,39 @@ +Pod::Spec.new do |spec| + spec.name = 'testing_support' + spec.version = '3.0.5-1-SNAPSHOT' + spec.homepage = '' + spec.source = { :http=> ''} + spec.authors = '' + spec.license = '' + spec.summary = '' + spec.vendored_frameworks = 'build/cocoapods/framework/testing_support.framework' + spec.libraries = 'c++' + + + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':testing-support', + 'PRODUCT_MODULE_NAME' => 'testing_support', + } + + spec.script_phases = [ + { + :name => 'Build testing_support', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end \ No newline at end of file