From 9e8a1d9bc036362b70f21fe8cdd20c5e5c46b01a Mon Sep 17 00:00:00 2001 From: Aleksey Mikhailov Date: Thu, 3 Jun 2021 20:39:04 +0700 Subject: [PATCH 1/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4720f74..beee25f 100755 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ This is a Kotlin MultiPlatform library that contains pagination logic for kotlin - kotlin 1.4.31 - 0.4.4 - 0.4.5 + - 0.4.6 ## Installation root build.gradle From d6d1037e2574c3bdae7dad02b6b028ba8713087e Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Tue, 29 Jun 2021 19:20:57 +0700 Subject: [PATCH 2/5] #45 temp commit --- .github/workflows/compilation-check.yml | 4 +- .github/workflows/publish.yml | 6 +- build.gradle.kts | 56 +++-------- buildSrc/build.gradle.kts | 24 ----- buildSrc/src/main/kotlin/Deps.kt | 99 ------------------- gradle/libs.versions.toml | 30 ++++++ gradle/wrapper/gradle-wrapper.properties | 2 +- paging-build-logic/build.gradle.kts | 17 ++++ .../kotlin/android-app-convention.gradle.kts | 32 ++++++ .../kotlin/android-base-convention.gradle.kts | 14 +++ .../android-library-convention.gradle.kts | 13 +++ .../android-publication-convention.gradle.kts | 15 +++ .../main/kotlin/detekt-convention.gradle.kts | 15 +++ .../kotlin/javadoc-stub-convention.gradle.kts | 16 +++ ...ultiplatform-library-convention.gradle.kts | 17 ++++ .../kotlin/publication-convention.gradle.kts | 70 +++++++++++++ paging/build.gradle.kts | 96 +++--------------- sample/android-app/build.gradle.kts | 43 ++------ sample/build.gradle.kts | 12 --- sample/mpp-library/build.gradle.kts | 35 ++++--- settings.gradle.kts | 22 +++++ 21 files changed, 326 insertions(+), 312 deletions(-) delete mode 100644 buildSrc/build.gradle.kts delete mode 100755 buildSrc/src/main/kotlin/Deps.kt create mode 100644 gradle/libs.versions.toml create mode 100644 paging-build-logic/build.gradle.kts create mode 100644 paging-build-logic/src/main/kotlin/android-app-convention.gradle.kts create mode 100644 paging-build-logic/src/main/kotlin/android-base-convention.gradle.kts create mode 100644 paging-build-logic/src/main/kotlin/android-library-convention.gradle.kts create mode 100644 paging-build-logic/src/main/kotlin/android-publication-convention.gradle.kts create mode 100644 paging-build-logic/src/main/kotlin/detekt-convention.gradle.kts create mode 100644 paging-build-logic/src/main/kotlin/javadoc-stub-convention.gradle.kts create mode 100644 paging-build-logic/src/main/kotlin/multiplatform-library-convention.gradle.kts create mode 100644 paging-build-logic/src/main/kotlin/publication-convention.gradle.kts delete mode 100644 sample/build.gradle.kts diff --git a/.github/workflows/compilation-check.yml b/.github/workflows/compilation-check.yml index 7948e92..5717c35 100644 --- a/.github/workflows/compilation-check.yml +++ b/.github/workflows/compilation-check.yml @@ -12,10 +12,10 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Set up JDK 1.8 + - name: Set up JDK 11 uses: actions/setup-java@v1 with: - java-version: 1.8 + java-version: 11 - name: Check runtime run: ./gradlew build publishToMavenLocal syncMultiPlatformLibraryDebugFrameworkIosX64 - name: Install pods diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9381e6e..380861e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -20,10 +20,10 @@ jobs: SIGNING_KEY: ${{ secrets.GPG_KEY_CONTENTS }} steps: - uses: actions/checkout@v1 - - name: Set up JDK 1.8 + - name: Set up JDK 11 uses: actions/setup-java@v1 with: - java-version: 1.8 + java-version: 11 - name: Publish run: ./gradlew publish release: @@ -39,6 +39,6 @@ jobs: with: commitish: ${{ github.ref }} tag_name: release/${{ github.event.inputs.version }} - release_name: Release ${{ github.event.inputs.version }} + release_name: ${{ github.event.inputs.version }} body: "Will be filled later" draft: true \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 9f452b5..236e316 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,61 +1,37 @@ /* * Copyright 2020 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. */ +import org.gradle.api.internal.artifacts.DefaultModuleVersionSelector buildscript { repositories { mavenCentral() google() - - jcenter { - content { - includeGroup("org.jetbrains.trove4j") - } - } + gradlePluginPortal() } dependencies { - plugin(Deps.Plugins.mokoUnits) - } -} + classpath("dev.icerock.moko:units-generator:0.6.0") -plugins { - plugin(Deps.Plugins.detekt).apply(false) + classpath(":paging-build-logic") + } } allprojects { - repositories { - mavenCentral() - google() - - jcenter { - content { - includeGroup("org.jetbrains.trove4j") - includeGroup("org.jetbrains.kotlinx") - } - } + plugins.withId("org.gradle.maven-publish") { + group = "dev.icerock.moko" + version = libs.versions.mokoPagingVersion.get() } - - plugins.withId(Deps.Plugins.androidLibrary.id) { - configure { - compileSdkVersion(Deps.Android.compileSdk) - - defaultConfig { - minSdkVersion(Deps.Android.minSdk) - targetSdkVersion(Deps.Android.targetSdk) - } + configurations.configureEach { + resolutionStrategy { + val coroutines: MinimalExternalModuleDependency = rootProject.libs.coroutines.get() + val forcedCoroutines: ModuleVersionSelector = DefaultModuleVersionSelector.newSelector( + coroutines.module, + coroutines.versionConstraint.requiredVersion + ) + force(forcedCoroutines) } } - - apply(plugin = Deps.Plugins.detekt.id) - - configure { - input.setFrom("src/commonMain/kotlin", "src/androidMain/kotlin", "src/iosMain/kotlin") - } - - dependencies { - "detektPlugins"(Deps.Libs.Detekt.detektFormatting) - } } tasks.register("clean", Delete::class).configure { diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts deleted file mode 100644 index 24825a7..0000000 --- a/buildSrc/build.gradle.kts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. - */ - -plugins { - id("org.jetbrains.kotlin.jvm") version("1.4.31") -} - -repositories { - mavenCentral() - google() - - jcenter { - content { - includeGroup("org.jetbrains.trove4j") - } - } -} - -dependencies { - implementation("dev.icerock:mobile-multiplatform:0.9.1") - implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.31") - implementation("com.android.tools.build:gradle:4.1.2") -} diff --git a/buildSrc/src/main/kotlin/Deps.kt b/buildSrc/src/main/kotlin/Deps.kt deleted file mode 100755 index 6eb31b8..0000000 --- a/buildSrc/src/main/kotlin/Deps.kt +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2020 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. - */ - -object Deps { - private const val kotlinVersion = "1.4.31" - - private const val androidAppCompatVersion = "1.1.0" - private const val androidLifecycleVersion = "2.1.0" - private const val androidCoreTestingVersion = "2.1.0" - private const val recyclerViewVersion = "1.1.0" - private const val swipeRefreshLayoutVersion = "1.1.0" - - private const val detektVersion = "1.15.0" - - private const val ktorClientVersion = "1.4.0" - private const val coroutinesVersion = "1.4.2-native-mt" - private const val mokoMvvmVersion = "0.9.2" - private const val mokoResourcesVersion = "0.15.1" - private const val mokoUnitsVersion = "0.5.0" - const val mokoPagingVersion = "0.4.6" - - object Android { - const val compileSdk = 28 - const val targetSdk = 28 - const val minSdk = 16 - } - - object Plugins { - val androidApplication = GradlePlugin(id = "com.android.application") - val androidLibrary = GradlePlugin(id = "com.android.library") - val kotlinMultiplatform = GradlePlugin(id = "org.jetbrains.kotlin.multiplatform") - val kotlinKapt = GradlePlugin(id = "kotlin-kapt") - val kotlinAndroid = GradlePlugin(id = "kotlin-android") - val kotlinAndroidExtensions = GradlePlugin(id = "kotlin-android-extensions") - val mavenPublish = GradlePlugin(id = "org.gradle.maven-publish") - val signing = GradlePlugin(id = "signing") - - val mobileMultiplatform = GradlePlugin(id = "dev.icerock.mobile.multiplatform") - val iosFramework = GradlePlugin(id = "dev.icerock.mobile.multiplatform.ios-framework") - - val mokoResources = GradlePlugin( - id = "dev.icerock.mobile.multiplatform-resources", - module = "dev.icerock.moko:resources-generator:$mokoResourcesVersion" - ) - val mokoUnits = GradlePlugin( - id = "dev.icerock.mobile.multiplatform-units", - module = "dev.icerock.moko:units-generator:$mokoUnitsVersion" - ) - - val detekt = GradlePlugin( - id = "io.gitlab.arturbosch.detekt", - version = detektVersion - ) - } - - object Libs { - object Android { - const val appCompat = "androidx.appcompat:appcompat:$androidAppCompatVersion" - const val recyclerView = "androidx.recyclerview:recyclerview:$recyclerViewVersion" - const val lifecycle = "androidx.lifecycle:lifecycle-extensions:$androidLifecycleVersion" - const val swipeRefreshLayout = - "androidx.swiperefreshlayout:swiperefreshlayout:$swipeRefreshLayoutVersion" - const val coroutines = - "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion" - } - - object MultiPlatform { - const val coroutines = - "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion" - val ktorClient = MultiPlatformLibrary( - common = "io.ktor:ktor-client-core:$ktorClientVersion", - iosX64 = "io.ktor:ktor-client-ios:$ktorClientVersion", - android = "io.ktor:ktor-client-okhttp:$ktorClientVersion" - ) - const val mokoResources = - "dev.icerock.moko:resources:$mokoResourcesVersion" - val mokoUnits = "dev.icerock.moko:units:$mokoUnitsVersion" - .defaultMPL(ios = true) - val mokoMvvmLiveData = "dev.icerock.moko:mvvm-livedata:$mokoMvvmVersion" - .defaultMPL(ios = true) - val mokoMvvmState = "dev.icerock.moko:mvvm-state:$mokoMvvmVersion" - .defaultMPL(ios = true) - const val mokoPaging = "dev.icerock.moko:paging:$mokoPagingVersion" - } - - object Tests { - const val kotlinTestJUnit = - "org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion" - const val androidCoreTesting = - "androidx.arch.core:core-testing:$androidCoreTestingVersion" - } - - object Detekt { - const val detektFormatting = - "io.gitlab.arturbosch.detekt:detekt-formatting:$detektVersion" - } - } -} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..27af66d --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,30 @@ +[versions] +kotlinVersion = "1.4.31" +androidAppCompatVersion = "1.2.0" +androidLifecycleVersion = "2.1.0" +androidCoreTestingVersion = "2.1.0" +recyclerViewVersion = "1.1.0" +swipeRefreshLayoutVersion = "1.1.0" +detektVersion = "1.15.0" +ktorClientVersion = "1.6.0" +coroutinesVersion = "1.5.0-native-mt" +mokoMvvmVersion = "0.11.0" +mokoResourcesVersion = "0.16.0" +mokoUnitsVersion = "0.6.0" +mokoPagingVersion = "0.5.0" + +[libraries] +appCompat = { module = "androidx.appcompat:appcompat", version.ref = "androidAppCompatVersion" } +recyclerView = { module = "androidx.recyclerview:recyclerview", version.ref = "recyclerViewVersion" } +lifecycle = { module = "androidx.lifecycle:lifecycle-extensions", version.ref = "androidLifecycleVersion" } +swipeRefreshLayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref = "swipeRefreshLayoutVersion" } +coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutinesVersion" } +ktorClient = { module = "io.ktor:ktor-client-core", version.ref = "ktorClientVersion" } +mokoResources = { module = "dev.icerock.moko:resources", version.ref = "mokoResourcesVersion" } +mokoUnits = { module = "dev.icerock.moko:units", version.ref = "mokoUnitsVersion" } +mokoMvvmLiveData = { module = "dev.icerock.moko:mvvm-livedata", version.ref = "mokoMvvmVersion" } +mokoMvvmState = { module = "dev.icerock.moko:mvvm-state", version.ref = "mokoMvvmVersion" } +mokoPaging = { module = "dev.icerock.moko:paging", version.ref = "mokoPagingVersion" } +kotlinTestJUnit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlinVersion" } +androidCoreTesting = { module = "androidx.arch.core:core-testing", version.ref = "androidCoreTestingVersion" } +detektFormatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detektVersion" } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 6c9a224..0f80bbf 100755 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/paging-build-logic/build.gradle.kts b/paging-build-logic/build.gradle.kts new file mode 100644 index 0000000..84cbae3 --- /dev/null +++ b/paging-build-logic/build.gradle.kts @@ -0,0 +1,17 @@ +plugins { + `kotlin-dsl` +} + +repositories { + mavenCentral() + google() + + gradlePluginPortal() +} + +dependencies { + api("dev.icerock:mobile-multiplatform:0.12.0") + api("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20") + api("com.android.tools.build:gradle:4.2.1") + api("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.15.0") +} diff --git a/paging-build-logic/src/main/kotlin/android-app-convention.gradle.kts b/paging-build-logic/src/main/kotlin/android-app-convention.gradle.kts new file mode 100644 index 0000000..2859874 --- /dev/null +++ b/paging-build-logic/src/main/kotlin/android-app-convention.gradle.kts @@ -0,0 +1,32 @@ +/* + * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +plugins { + id("com.android.application") + id("android-base-convention") + id("kotlin-android") +} + +android { + dexOptions { + javaMaxHeapSize = "2g" + } + + buildTypes { + getByName("release") { + isMinifyEnabled = true + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + getByName("debug") { + isDebuggable = true + applicationIdSuffix = ".debug" + } + } + + packagingOptions { + exclude("META-INF/*.kotlin_module") + exclude("META-INF/AL2.0") + exclude("META-INF/LGPL2.1") + } +} diff --git a/paging-build-logic/src/main/kotlin/android-base-convention.gradle.kts b/paging-build-logic/src/main/kotlin/android-base-convention.gradle.kts new file mode 100644 index 0000000..7f67285 --- /dev/null +++ b/paging-build-logic/src/main/kotlin/android-base-convention.gradle.kts @@ -0,0 +1,14 @@ +/* + * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +import com.android.build.gradle.BaseExtension + +configure { + compileSdkVersion(30) + + defaultConfig { + minSdkVersion(16) + targetSdkVersion(30) + } +} diff --git a/paging-build-logic/src/main/kotlin/android-library-convention.gradle.kts b/paging-build-logic/src/main/kotlin/android-library-convention.gradle.kts new file mode 100644 index 0000000..c435401 --- /dev/null +++ b/paging-build-logic/src/main/kotlin/android-library-convention.gradle.kts @@ -0,0 +1,13 @@ +/* + * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +plugins { + id("com.android.library") + id("kotlin-android") + id("android-base-convention") +} + +android { + sourceSets.all { java.srcDir("src/$name/kotlin") } +} diff --git a/paging-build-logic/src/main/kotlin/android-publication-convention.gradle.kts b/paging-build-logic/src/main/kotlin/android-publication-convention.gradle.kts new file mode 100644 index 0000000..b4dae9e --- /dev/null +++ b/paging-build-logic/src/main/kotlin/android-publication-convention.gradle.kts @@ -0,0 +1,15 @@ +/* + * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +plugins { + id("publication-convention") +} + +afterEvaluate { + publishing.publications { + create("release", MavenPublication::class.java) { + from(components.getByName("release")) + } + } +} diff --git a/paging-build-logic/src/main/kotlin/detekt-convention.gradle.kts b/paging-build-logic/src/main/kotlin/detekt-convention.gradle.kts new file mode 100644 index 0000000..68343a8 --- /dev/null +++ b/paging-build-logic/src/main/kotlin/detekt-convention.gradle.kts @@ -0,0 +1,15 @@ +/* + * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +plugins { + id("io.gitlab.arturbosch.detekt") +} + +detekt { + input.setFrom("src/commonMain/kotlin", "src/androidMain/kotlin", "src/iosMain/kotlin", "src/main/kotlin") +} + +dependencies { + "detektPlugins"("io.gitlab.arturbosch.detekt:detekt-formatting:1.15.0") +} diff --git a/paging-build-logic/src/main/kotlin/javadoc-stub-convention.gradle.kts b/paging-build-logic/src/main/kotlin/javadoc-stub-convention.gradle.kts new file mode 100644 index 0000000..a1a2691 --- /dev/null +++ b/paging-build-logic/src/main/kotlin/javadoc-stub-convention.gradle.kts @@ -0,0 +1,16 @@ +/* + * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +plugins { + id("org.gradle.maven-publish") +} + +val javadocJar by tasks.registering(Jar::class) { + archiveClassifier.set("javadoc") +} + +publishing.publications.withType { + // Stub javadoc.jar artifact + artifact(javadocJar.get()) +} diff --git a/paging-build-logic/src/main/kotlin/multiplatform-library-convention.gradle.kts b/paging-build-logic/src/main/kotlin/multiplatform-library-convention.gradle.kts new file mode 100644 index 0000000..f203934 --- /dev/null +++ b/paging-build-logic/src/main/kotlin/multiplatform-library-convention.gradle.kts @@ -0,0 +1,17 @@ +/* + * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +plugins { + id("com.android.library") + id("org.jetbrains.kotlin.multiplatform") + id("android-base-convention") + id("dev.icerock.mobile.multiplatform.android-manifest") +} + +kotlin { + android { + publishLibraryVariants("release", "debug") + } + ios() +} diff --git a/paging-build-logic/src/main/kotlin/publication-convention.gradle.kts b/paging-build-logic/src/main/kotlin/publication-convention.gradle.kts new file mode 100644 index 0000000..e844fd7 --- /dev/null +++ b/paging-build-logic/src/main/kotlin/publication-convention.gradle.kts @@ -0,0 +1,70 @@ +/* + * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +import java.util.Base64 + +plugins { + id("javadoc-stub-convention") + id("org.gradle.maven-publish") + id("signing") +} + +publishing { + repositories.maven("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") { + name = "OSSRH" + + credentials { + username = System.getenv("OSSRH_USER") + password = System.getenv("OSSRH_KEY") + } + } + + publications.withType { + // Provide artifacts information requited by Maven Central + pom { + name.set("MOKO paging") + description.set("Pagination logic in common code for mobile (android & ios) Kotlin Multiplatform development") + url.set("https://github.com/icerockdev/moko-paging") + licenses { + license { + name.set("Apache-2.0") + distribution.set("repo") + url.set("https://github.com/icerockdev/moko-paging/blob/master/LICENSE.md") + } + } + + developers { + developer { + id.set("Alex009") + name.set("Aleksey Mikhailov") + email.set("aleksey.mikhailov@icerockdev.com") + } + developer { + id.set("Tetraquark") + name.set("Vladislav Areshkin") + email.set("vareshkin@icerockdev.com") + } + } + + scm { + connection.set("scm:git:ssh://github.com/icerockdev/moko-paging.git") + developerConnection.set("scm:git:ssh://github.com/icerockdev/moko-paging.git") + url.set("https://github.com/icerockdev/moko-paging") + } + } + } +} + + +signing { + val signingKeyId: String? = System.getenv("SIGNING_KEY_ID") + val signingPassword: String? = System.getenv("SIGNING_PASSWORD") + val signingKey: String? = System.getenv("SIGNING_KEY")?.let { base64Key -> + String(Base64.getDecoder().decode(base64Key)) + } + if (signingKeyId != null) { + useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) + sign(publishing.publications) + } +} diff --git a/paging/build.gradle.kts b/paging/build.gradle.kts index d112e0c..01a3c5a 100644 --- a/paging/build.gradle.kts +++ b/paging/build.gradle.kts @@ -2,95 +2,25 @@ * Copyright 2020 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. */ -import java.util.Base64 - plugins { - plugin(Deps.Plugins.androidLibrary) - plugin(Deps.Plugins.kotlinMultiplatform) - plugin(Deps.Plugins.kotlinAndroidExtensions) - plugin(Deps.Plugins.mobileMultiplatform) - plugin(Deps.Plugins.mavenPublish) - plugin(Deps.Plugins.signing) + id("multiplatform-library-convention") + id("kotlin-parcelize") + id("dev.icerock.mobile.multiplatform.android-manifest") + id("publication-convention") } group = "dev.icerock.moko" -version = Deps.mokoPagingVersion +version = libs.versions.mokoPagingVersion.get() dependencies { - commonMainImplementation(Deps.Libs.MultiPlatform.coroutines) - commonMainApi(Deps.Libs.MultiPlatform.mokoMvvmLiveData.common) - commonMainApi(Deps.Libs.MultiPlatform.mokoMvvmState.common) - - androidMainImplementation(Deps.Libs.Android.appCompat) - - commonTestImplementation(Deps.Libs.Tests.kotlinTestJUnit) - androidTestImplementation(Deps.Libs.Tests.androidCoreTesting) - androidTestImplementation(Deps.Libs.MultiPlatform.ktorClient.android!!) - commonTestImplementation(Deps.Libs.MultiPlatform.ktorClient.common) - iosX64TestImplementation(Deps.Libs.MultiPlatform.ktorClient.iosX64!!) - iosX64TestImplementation(Deps.Libs.MultiPlatform.coroutines) { - isForce = true - } -} -val javadocJar by tasks.registering(Jar::class) { - archiveClassifier.set("javadoc") -} - -publishing { - repositories.maven("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") { - name = "OSSRH" + commonMainImplementation(libs.coroutines) + commonMainApi(libs.mokoMvvmLiveData) + commonMainApi(libs.mokoMvvmState) - credentials { - username = System.getenv("OSSRH_USER") - password = System.getenv("OSSRH_KEY") - } - } - - publications.withType { - // Stub javadoc.jar artifact - artifact(javadocJar.get()) - - // Provide artifacts information requited by Maven Central - pom { - name.set("MOKO paging") - description.set("Pagination logic in common code for mobile (android & ios) Kotlin Multiplatform development") - url.set("https://github.com/icerockdev/moko-paging") - licenses { - license { - url.set("https://github.com/icerockdev/moko-paging/blob/master/LICENSE.md") - } - } - - developers { - developer { - id.set("Alex009") - name.set("Aleksey Mikhailov") - email.set("aleksey.mikhailov@icerockdev.com") - } - developer { - id.set("Tetraquark") - name.set("Vladislav Areshkin") - email.set("vareshkin@icerockdev.com") - } - } - - scm { - connection.set("scm:git:ssh://github.com/icerockdev/moko-paging.git") - developerConnection.set("scm:git:ssh://github.com/icerockdev/moko-paging.git") - url.set("https://github.com/icerockdev/moko-paging") - } - } - } -} + "androidMainImplementation"(libs.appCompat) -signing { - val signingKeyId: String? = System.getenv("SIGNING_KEY_ID") - val signingPassword: String? = System.getenv("SIGNING_PASSWORD") - val signingKey: String? = System.getenv("SIGNING_KEY")?.let { base64Key -> - String(Base64.getDecoder().decode(base64Key)) - } - if (signingKeyId != null) { - useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) - sign(publishing.publications) - } + commonTestImplementation(libs.kotlinTestJUnit) + androidTestImplementation(libs.androidCoreTesting) + commonTestImplementation(libs.ktorClient) + iosX64TestImplementation(libs.coroutines) } diff --git a/sample/android-app/build.gradle.kts b/sample/android-app/build.gradle.kts index 0fe1fa7..f98deb4 100644 --- a/sample/android-app/build.gradle.kts +++ b/sample/android-app/build.gradle.kts @@ -3,57 +3,32 @@ */ plugins { - plugin(Deps.Plugins.androidApplication) - plugin(Deps.Plugins.kotlinAndroid) - plugin(Deps.Plugins.kotlinKapt) - plugin(Deps.Plugins.mokoUnits) + id("android-app-convention") + id("kotlin-android") + id("kotlin-kapt") + id("dev.icerock.mobile.multiplatform-units") } android { - compileSdkVersion(Deps.Android.compileSdk) - buildFeatures.dataBinding = true - dexOptions { - javaMaxHeapSize = "2g" - } - defaultConfig { - minSdkVersion(Deps.Android.minSdk) - targetSdkVersion(Deps.Android.targetSdk) - applicationId = "dev.icerock.moko.samples.paging" versionCode = 1 versionName = "0.1.0" - vectorDrawables.useSupportLibrary = true testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } - - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") - } - getByName("debug") { - isDebuggable = true - applicationIdSuffix = ".debug" - } - } - - packagingOptions { - exclude("META-INF/*.kotlin_module") - } } dependencies { - implementation(Deps.Libs.Android.appCompat) - implementation(Deps.Libs.Android.recyclerView) - implementation(Deps.Libs.Android.lifecycle) - implementation(Deps.Libs.Android.swipeRefreshLayout) + implementation(libs.appCompat) + implementation(libs.recyclerView) + implementation(libs.lifecycle) + implementation(libs.swipeRefreshLayout) - implementation(project(":sample:mpp-library")) + implementation(projects.sample.mppLibrary) } multiplatformUnits { diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts deleted file mode 100644 index a1f5d10..0000000 --- a/sample/build.gradle.kts +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright 2020 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. - */ - -subprojects { - configurations.all { - resolutionStrategy.dependencySubstitution { - substitute(module(Deps.Libs.MultiPlatform.mokoPaging)) - .with(project(":paging")) - } - } -} diff --git a/sample/mpp-library/build.gradle.kts b/sample/mpp-library/build.gradle.kts index 509ebc6..8617d4a 100644 --- a/sample/mpp-library/build.gradle.kts +++ b/sample/mpp-library/build.gradle.kts @@ -3,26 +3,33 @@ */ plugins { - plugin(Deps.Plugins.androidLibrary) - plugin(Deps.Plugins.kotlinMultiplatform) - plugin(Deps.Plugins.mobileMultiplatform) - plugin(Deps.Plugins.iosFramework) + id("com.android.library") + id("android-base-convention") + id("detekt-convention") + id("org.jetbrains.kotlin.multiplatform") + id("dev.icerock.mobile.multiplatform.android-manifest") + id("dev.icerock.mobile.multiplatform.ios-framework") +} + +kotlin { + android() + ios() } dependencies { - commonMainImplementation(Deps.Libs.MultiPlatform.coroutines) + commonMainImplementation(libs.coroutines) - commonMainApi(Deps.Libs.MultiPlatform.mokoPaging) - commonMainApi(Deps.Libs.MultiPlatform.mokoUnits.common) - commonMainApi(Deps.Libs.MultiPlatform.mokoMvvmLiveData.common) - commonMainApi(Deps.Libs.MultiPlatform.mokoMvvmState.common) - commonMainApi(Deps.Libs.MultiPlatform.mokoResources) + commonMainApi(projects.paging) + commonMainApi(libs.mokoUnits) + commonMainApi(libs.mokoMvvmLiveData) + commonMainApi(libs.mokoMvvmState) + commonMainApi(libs.mokoResources) - androidMainImplementation(Deps.Libs.Android.lifecycle) + "androidMainImplementation"(libs.lifecycle) } framework { - export(Deps.Libs.MultiPlatform.mokoUnits) - export(Deps.Libs.MultiPlatform.mokoMvvmLiveData) - export(Deps.Libs.MultiPlatform.mokoMvvmState) + export(libs.mokoUnits) + export(libs.mokoMvvmLiveData) + export(libs.mokoMvvmState) } diff --git a/settings.gradle.kts b/settings.gradle.kts index c2f6f75..c2c3322 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,6 +2,28 @@ * Copyright 2020 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. */ +/* + * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +enableFeaturePreview("VERSION_CATALOGS") +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") + +dependencyResolutionManagement { + repositories { + mavenCentral() + google() + + jcenter { + content { + includeGroup("org.jetbrains.kotlinx") + } + } + } +} + +includeBuild("paging-build-logic") + include(":paging") include(":sample:android-app") include(":sample:mpp-library") From 20702cd535585c36a93f185e2dd7012c33c37ddf Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Thu, 1 Jul 2021 10:17:17 +0700 Subject: [PATCH 3/5] #45 creating httpClient using mockEngine and readme changes --- README.md | 31 +++---------------- gradle/libs.versions.toml | 3 +- paging/build.gradle.kts | 2 +- .../icerock/moko/paging/IntegrationTests.kt | 28 ++++++++++++++--- 4 files changed, 31 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index beee25f..03c76f2 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ![moko-paging](img/logo.png) -[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) [![Download](https://img.shields.io/maven-central/v/dev.icerock.moko/paging) ](https://repo1.maven.org/maven2/dev/icerock/moko/paging) ![kotlin-version](https://img.shields.io/badge/kotlin-1.4.31-orange) +[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) [![Download](https://img.shields.io/maven-central/v/dev.icerock.moko/paging) ](https://repo1.maven.org/maven2/dev/icerock/moko/paging) ![kotlin-version](https://kotlin-version.aws.icerock.dev/kotlin-version?group=dev.icerock.moko&name=paging) # Mobile Kotlin paging This is a Kotlin MultiPlatform library that contains pagination logic for kotlin multiplatform @@ -7,7 +7,6 @@ This is a Kotlin MultiPlatform library that contains pagination logic for kotlin ## Table of Contents - [Features](#features) - [Requirements](#requirements) -- [Versions](#versions) - [Installation](#installation) - [Usage](#usage) - [Samples](#samples) @@ -22,31 +21,9 @@ This is a Kotlin MultiPlatform library that contains pagination logic for kotlin - Observing states of **Pagination** using `LiveData` from **moko-mvvm**. ## Requirements -- Gradle version 6.0+ +- Gradle version 6.8+ - Android API 16+ -- iOS version 9.0+ - -## Versions -### Bintray -- kotlin 1.3.61 - - 0.1.0 -- kotlin 1.3.70 - - 0.2.0 - - 0.2.1 - - 0.2.2 - - 0.3.0 - - 0.3.1 -- kotlin 1.4.0 - - 0.4.0 -- kotlin 1.4.21 - - 0.4.1 - - 0.4.2 - - 0.4.3 -### mavenCentral -- kotlin 1.4.31 - - 0.4.4 - - 0.4.5 - - 0.4.6 +- iOS version 11.0+ ## Installation root build.gradle @@ -61,7 +38,7 @@ allprojects { project build.gradle ```groovy dependencies { - commonMainApi("dev.icerock.moko:paging:0.4.6") + commonMainApi("dev.icerock.moko:paging:0.5.0") } ``` diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 27af66d..b0edf92 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -27,4 +27,5 @@ mokoMvvmState = { module = "dev.icerock.moko:mvvm-state", version.ref = "mokoMvv mokoPaging = { module = "dev.icerock.moko:paging", version.ref = "mokoPagingVersion" } kotlinTestJUnit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlinVersion" } androidCoreTesting = { module = "androidx.arch.core:core-testing", version.ref = "androidCoreTestingVersion" } -detektFormatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detektVersion" } \ No newline at end of file +detektFormatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detektVersion" } +ktorClientMock = { module = "io.ktor:ktor-client-mock", version.ref = "ktorClientVersion" } diff --git a/paging/build.gradle.kts b/paging/build.gradle.kts index 01a3c5a..4253867 100644 --- a/paging/build.gradle.kts +++ b/paging/build.gradle.kts @@ -16,7 +16,7 @@ dependencies { commonMainImplementation(libs.coroutines) commonMainApi(libs.mokoMvvmLiveData) commonMainApi(libs.mokoMvvmState) - + commonMainApi(libs.ktorClientMock) "androidMainImplementation"(libs.appCompat) commonTestImplementation(libs.kotlinTestJUnit) diff --git a/paging/src/commonTest/kotlin/dev/icerock/moko/paging/IntegrationTests.kt b/paging/src/commonTest/kotlin/dev/icerock/moko/paging/IntegrationTests.kt index 6e0a269..0ab2147 100644 --- a/paging/src/commonTest/kotlin/dev/icerock/moko/paging/IntegrationTests.kt +++ b/paging/src/commonTest/kotlin/dev/icerock/moko/paging/IntegrationTests.kt @@ -5,19 +5,39 @@ package dev.icerock.moko.paging import io.ktor.client.HttpClient +import io.ktor.client.engine.mock.MockEngine +import io.ktor.client.engine.mock.respondOk import io.ktor.client.request.get -import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.async import kotlinx.coroutines.cancel import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlin.test.Test -import kotlin.test.assertNotNull -import kotlin.test.assertTrue class IntegrationTests : BaseTestsClass() { - private val httpClient = HttpClient() + private val httpClient = HttpClient(MockEngine) { + engine { + addHandler { request -> + when (request.url.encodedPath) { + "http://api.icndb.com/jokes/random" -> { + delay(200) + respondOk(""" + { + "type": "success", + "value": { + "id": 318, + "joke": "If you work in an office with Chuck Norris, don't ask him for his three-hole-punch.", + "categories": [] + } + } + """.trimIndent()) + } + else -> error("Unhandled ${request.url.encodedPath}") + } + } + } + } @Test fun parallelRequests() = runTest { From c2c18f30925c5e878bcb8b4f692b3d30dcc13b95 Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Thu, 1 Jul 2021 10:22:44 +0700 Subject: [PATCH 4/5] #45 fixes --- .../kotlin/dev/icerock/moko/paging/IntegrationTests.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/paging/src/commonTest/kotlin/dev/icerock/moko/paging/IntegrationTests.kt b/paging/src/commonTest/kotlin/dev/icerock/moko/paging/IntegrationTests.kt index 0ab2147..3d48a18 100644 --- a/paging/src/commonTest/kotlin/dev/icerock/moko/paging/IntegrationTests.kt +++ b/paging/src/commonTest/kotlin/dev/icerock/moko/paging/IntegrationTests.kt @@ -8,6 +8,7 @@ import io.ktor.client.HttpClient import io.ktor.client.engine.mock.MockEngine import io.ktor.client.engine.mock.respondOk import io.ktor.client.request.get +import io.ktor.http.fullPath import kotlinx.coroutines.async import kotlinx.coroutines.cancel import kotlinx.coroutines.coroutineScope @@ -19,7 +20,7 @@ class IntegrationTests : BaseTestsClass() { private val httpClient = HttpClient(MockEngine) { engine { addHandler { request -> - when (request.url.encodedPath) { + when (request.url.fullPath) { "http://api.icndb.com/jokes/random" -> { delay(200) respondOk(""" @@ -33,7 +34,7 @@ class IntegrationTests : BaseTestsClass() { } """.trimIndent()) } - else -> error("Unhandled ${request.url.encodedPath}") + else -> error("Unhandled ${request.url.fullPath}") } } } From d010507f1aa862d1e4b4653abb296b209023b418 Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Thu, 1 Jul 2021 11:01:41 +0700 Subject: [PATCH 5/5] #45 removed unused --- gradle/libs.versions.toml | 5 +---- settings.gradle.kts | 4 ---- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b0edf92..8ac9cb9 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,11 +1,10 @@ [versions] -kotlinVersion = "1.4.31" +kotlinVersion = "1.5.20" androidAppCompatVersion = "1.2.0" androidLifecycleVersion = "2.1.0" androidCoreTestingVersion = "2.1.0" recyclerViewVersion = "1.1.0" swipeRefreshLayoutVersion = "1.1.0" -detektVersion = "1.15.0" ktorClientVersion = "1.6.0" coroutinesVersion = "1.5.0-native-mt" mokoMvvmVersion = "0.11.0" @@ -24,8 +23,6 @@ mokoResources = { module = "dev.icerock.moko:resources", version.ref = "mokoReso mokoUnits = { module = "dev.icerock.moko:units", version.ref = "mokoUnitsVersion" } mokoMvvmLiveData = { module = "dev.icerock.moko:mvvm-livedata", version.ref = "mokoMvvmVersion" } mokoMvvmState = { module = "dev.icerock.moko:mvvm-state", version.ref = "mokoMvvmVersion" } -mokoPaging = { module = "dev.icerock.moko:paging", version.ref = "mokoPagingVersion" } kotlinTestJUnit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlinVersion" } androidCoreTesting = { module = "androidx.arch.core:core-testing", version.ref = "androidCoreTestingVersion" } -detektFormatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detektVersion" } ktorClientMock = { module = "io.ktor:ktor-client-mock", version.ref = "ktorClientVersion" } diff --git a/settings.gradle.kts b/settings.gradle.kts index c2c3322..a0720f0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,10 +2,6 @@ * Copyright 2020 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. */ -/* - * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. - */ - enableFeaturePreview("VERSION_CATALOGS") enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")