Skip to content

Commit

Permalink
Move paging extensions to own module
Browse files Browse the repository at this point in the history
Create testing-support shared module
  • Loading branch information
jeffdgr8 committed May 17, 2023
1 parent 4ccf08f commit 6e807a0
Show file tree
Hide file tree
Showing 36 changed files with 577 additions and 128 deletions.
56 changes: 4 additions & 52 deletions couchbase-lite-ee-ktx/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
}

Expand Down Expand Up @@ -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)
Expand All @@ -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)
}
Expand All @@ -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)
Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
114 changes: 114 additions & 0 deletions couchbase-lite-ee-paging/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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<Jar>("javadocJar") {
dependsOn(tasks.dokkaHtml)
archiveClassifier.set("javadoc")
from(dokkaOutputDir)
}

publishing.publications.withType<MavenPublication> {
artifact(javadocJar)
}

tasks.withType<KotlinNativeSimulatorTest> {
device.set("iPhone 14")
}
1 change: 1 addition & 0 deletions couchbase-lite-ee-paging/src
54 changes: 4 additions & 50 deletions couchbase-lite-ktx/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
}

Expand Down Expand Up @@ -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)
Expand All @@ -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)
}
Expand All @@ -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)
Expand All @@ -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)
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

This file was deleted.

Loading

0 comments on commit 6e807a0

Please sign in to comment.