diff --git a/.github/workflows/compilation-check.yml b/.github/workflows/compilation-check.yml index 8ab363a..2b4ebf4 100644 --- a/.github/workflows/compilation-check.yml +++ b/.github/workflows/compilation-check.yml @@ -12,13 +12,13 @@ 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 - - name: Build K/N cache - run: ./gradlew :network:runCommonizer + java-version: 11 - name: Check plugin run: ./gradlew -p network-generator detekt build publishToMavenLocal - name: Check runtime - run: ./gradlew detekt build publishToMavenLocal + run: ./gradlew detekt build publishToMavenLocal syncMultiPlatformLibraryDebugFrameworkIosX64 + - name: Check iOS + run: cd sample/ios-app && xcodebuild -scheme TestProj -workspace TestProj.xcworkspace -configuration Debug -sdk iphonesimulator -arch x86_64 build CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO | xcpretty diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f47a1d3..96a23ef 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,12 +21,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 - - name: Build K/N cache - run: ./gradlew :network:runCommonizer + java-version: 11 - name: Publish plugin run: ./gradlew -p network-generator publishMavenJavaPublicationToOSSRHRepository - name: Publish library @@ -44,6 +42,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 diff --git a/README.md b/README.md index eee6a22..02a7e72 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ ![moko-network](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/network) ](https://repo1.maven.org/maven2/dev/icerock/moko/network) ![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/network) ](https://repo1.maven.org/maven2/dev/icerock/moko/network) ![kotlin-version](https://kotlin-version.aws.icerock.dev/kotlin-version?group=dev.icerock.moko&name=network) # Mobile Kotlin network components This is a Kotlin MultiPlatform library that provide network components for iOS & Android. Library is addition to [ktor-client](https://github.com/ktorio/ktor) with gradle plugin to generate entities @@ -24,43 +23,9 @@ This is a Kotlin MultiPlatform library that provide network components for iOS & - **RefreshTokenFeature** feature to ktor-client that handle Unauthorized response from server, try to update token and repeat failed request in case, when token update was successful; ## Requirements -- Gradle version 6.0+ +- Gradle version 6.8+ - Android API 16+ -- iOS version 9.0+ - -## Versions -### Bintray -- kotlin 1.3.50 - - 0.1.0 - - 0.1.1 -- kotlin 1.3.61 - - 0.2.0 - - 0.3.0 - - 0.4.0 - - 0.5.0 - - 0.5.1 -- kotlin 1.3.70 - - 0.6.0 - - 0.7.0 -- kotlin 1.4.10 - - 0.8.0 -- kotlin 1.4.21 - - 0.9.0 - - 0.9.1 - - 0.9.2 - - 0.9.3 - - 0.10.0 -- kotlin 1.4.31 - - 0.11.0 - - 0.12.0 - - 0.13.0 -### mavenCentral - - 0.14.0 - - 0.14.1 - - 0.14.2 - - 0.15.0 - - 0.15.1 - - 0.15.2 +- iOS version 11.0+ ## Installation root build.gradle @@ -71,7 +36,7 @@ buildscript { } dependencies { - classpath "dev.icerock.moko:network-generator:0.15.2" + classpath "dev.icerock.moko:network-generator:0.16.0" } } @@ -88,7 +53,7 @@ project build.gradle apply plugin: "dev.icerock.mobile.multiplatform-network-generator" dependencies { - commonMainApi("dev.icerock.moko:network:0.15.2") + commonMainApi("dev.icerock.moko:network:0.16.0") } ``` diff --git a/build.gradle.kts b/build.gradle.kts index 8e3482e..31f0a5e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,12 +1,7 @@ /* * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. */ - -import java.util.Base64 - -plugins { - id("io.gitlab.arturbosch.detekt") version("1.15.0") apply(false) -} +import org.gradle.api.internal.artifacts.DefaultModuleVersionSelector buildscript { repositories { @@ -15,107 +10,27 @@ buildscript { gradlePluginPortal() } dependencies { - classpath("dev.icerock.moko:resources-generator:0.15.1") + classpath("dev.icerock.moko:resources-generator:0.16.0") classpath("dev.icerock.moko:network-generator") // substituted - classpath("org.jetbrains.kotlin:kotlin-serialization:1.4.31") - classpath("gradle:network-deps:1") + classpath("org.jetbrains.kotlin:kotlin-serialization:1.5.20") + + classpath(":network-build-logic") } } allprojects { - apply(plugin = Deps.Plugins.detekt.id) - - configure { - input.setFrom("src/commonMain/kotlin", "src/androidMain/kotlin", "src/iosMain/kotlin") - } - - dependencies { - "detektPlugins"(Deps.Libs.Detekt.detektFormatting) - } - - plugins.withId(Deps.Plugins.androidLibrary.id) { - configure { - compileSdkVersion(Deps.Android.compileSdk) - - defaultConfig { - minSdkVersion(Deps.Android.minSdk) - targetSdkVersion(Deps.Android.targetSdk) - } - } - } - - plugins.withId(Deps.Plugins.mavenPublish.id) { + plugins.withId("org.gradle.maven-publish") { group = "dev.icerock.moko" - version = Deps.mokoNetworkVersion - - val javadocJar by tasks.registering(Jar::class) { - archiveClassifier.set("javadoc") - } - - configure { - 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 { - // Stub javadoc.jar artifact - artifact(javadocJar.get()) - - // Provide artifacts information requited by Maven Central - pom { - name.set("MOKO network") - description.set("Network components with codegeneration of rest api for mobile (android & ios) Kotlin Multiplatform development") - url.set("https://github.com/icerockdev/moko-network") - licenses { - license { - url.set("https://github.com/icerockdev/moko-network/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") - } - developer { - id.set("Dorofeev") - name.set("Andrey Dorofeev") - email.set("adorofeev@icerockdev.com") - } - } - - scm { - connection.set("scm:git:ssh://github.com/icerockdev/moko-network.git") - developerConnection.set("scm:git:ssh://github.com/icerockdev/moko-network.git") - url.set("https://github.com/icerockdev/moko-network") - } - } - } - - apply(plugin = "signing") - - configure { - 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(publications) - } - } + version = libs.versions.mokoNetworkVersion.get() + } + configurations.configureEach { + resolutionStrategy { + val coroutines: MinimalExternalModuleDependency = rootProject.libs.coroutines.get() + val forcedCoroutines: ModuleVersionSelector = DefaultModuleVersionSelector.newSelector( + coroutines.module, + coroutines.versionConstraint.requiredVersion + ) + force(forcedCoroutines) } } } diff --git a/gradle.properties b/gradle.properties index c6b3fc6..acaabde 100755 --- a/gradle.properties +++ b/gradle.properties @@ -3,6 +3,8 @@ org.gradle.configureondemand=false org.gradle.parallel=true kotlin.code.style=official + +kotlin.mpp.stability.nowarn=true kotlin.native.enableDependencyPropagation=false kotlin.mpp.enableGranularSourceSetsMetadata=true kotlin.mpp.enableCompatibilityMetadataVariant=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..8b6a65d --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,56 @@ +[versions] +kotlinVersion = "1.5.20" + +lifecycleVersion = "2.2.0" +glideVersion = "4.9.0" +androidAppCompatVersion = "1.2.0" +espressoCoreVersion = "3.2.0" +testRunnerVersion = "1.2.0" +testExtJunitVersion = "1.1.1" +androidxTestVersion = "1.3.0" +robolectricVersion = "4.3" +openApiGeneratorVersion = "5.1.0" +guavaVersion = "30.1-jre" +kotlinxSerializationVersion = "1.1.0" +coroutinesVersion = "1.5.0-native-mt" +ktorClientVersion = "1.6.0" +mokoResourcesVersion = "0.16.0" +mokoMvvmVersion = "0.11.0" +mokoErrorsVersion = "0.4.0" +mokoTestVersion = "0.4.0" +mokoNetworkVersion = "0.16.0" +kbignumVersion = "2.0.6" + +[libraries] +appCompat = { module = "androidx.appcompat:appcompat", version.ref = "androidAppCompatVersion" } +glide = { module = "com.github.bumptech.glide:glide", version.ref = "glideVersion" } +lifecycle = { module = "androidx.lifecycle:lifecycle-extensions", version.ref = "lifecycleVersion" } +ktorClientOkHttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktorClientVersion" } +mokoMvvmDataBinding = { module = "dev.icerock.moko:mvvm-databinding", version.ref = "mokoMvvmVersion" } +espressoCore = { module = "androidx.test.espresso:espresso-core", version.ref = "espressoCoreVersion" } +kotlinTestJUnit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlinVersion" } +testCore = { module = "androidx.test:core", version.ref = "androidxTestVersion" } +robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectricVersion" } +testRunner = { module = "androidx.test:runner", version.ref = "testRunnerVersion" } +testRules = { module = "androidx.test:rules", version.ref = "testRunnerVersion" } +testExtJunit = { module = "androidx.test.ext:junit", version.ref = "testExtJunitVersion" } +kotlinSerialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationVersion" } +coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutinesVersion" } +ktorClient = { module = "io.ktor:ktor-client-core", version.ref = "ktorClientVersion" } +ktorClientLogging = { module = "io.ktor:ktor-client-logging", version.ref = "ktorClientVersion" } +ktorClientMock = { module = "io.ktor:ktor-client-mock", version.ref = "ktorClientVersion" } +mokoResources = { module = "dev.icerock.moko:resources", version.ref = "mokoResourcesVersion" } +mokoMvvmCore = { module = "dev.icerock.moko:mvvm-core", version.ref = "mokoMvvmVersion" } +mokoMvvmLiveData = { module = "dev.icerock.moko:mvvm-livedata", version.ref = "mokoMvvmVersion" } +mokoErrors = { module = "dev.icerock.moko:errors", version.ref = "mokoErrorsVersion" } +mokoNetwork = { module = "dev.icerock.moko:network", version.ref = "mokoNetworkVersion" } +mokoNetworkErrors = { module = "dev.icerock.moko:network-errors", version.ref = "mokoNetworkVersion" } +mokoNetworkBignum = { module = "dev.icerock.moko:network-bignum", version.ref = "mokoNetworkVersion" } +kbignum = { module = "com.soywiz.korlibs.kbignum:kbignum", version.ref = "kbignumVersion" } +kotlinTest = { module = "org.jetbrains.kotlin:kotlin-test-common", version.ref = "kotlinVersion" } +kotlinTestAnnotations = { module = "org.jetbrains.kotlin:kotlin-test-annotations-common", version.ref = "kotlinVersion" } +mokoTest = { module = "dev.icerock.moko:test-core", version.ref = "mokoTestVersion" } +kotlinGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlinVersion" } +ktorClientIos = { module = "io.ktor:ktor-client-ios", version.ref = "ktorClientVersion" } +openApiGenerator = { module = "org.openapitools:openapi-generator-gradle-plugin", version.ref = "openApiGeneratorVersion" } +guava = { module = "com.google.guava:guava", version.ref = "guavaVersion" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8cf6eb5..29e4134 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.8.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/network-bignum/build.gradle.kts b/network-bignum/build.gradle.kts index 85397f3..a22b8eb 100644 --- a/network-bignum/build.gradle.kts +++ b/network-bignum/build.gradle.kts @@ -3,15 +3,15 @@ */ plugins { - id("com.android.library") - id("org.jetbrains.kotlin.multiplatform") - id("dev.icerock.mobile.multiplatform") - id("org.gradle.maven-publish") + id("multiplatform-library-convention") + id("dev.icerock.mobile.multiplatform.android-manifest") + id("publication-convention") + id("javadoc-stub-convention") } dependencies { - commonMainImplementation(Deps.Libs.MultiPlatform.kotlinSerialization) - commonMainApi(Deps.Libs.MultiPlatform.kbignum) + commonMainImplementation(libs.kotlinSerialization) + commonMainApi(libs.kbignum) - commonMainImplementation(project(":network")) + commonMainImplementation(projects.network) } diff --git a/network-build-logic/build.gradle.kts b/network-build-logic/build.gradle.kts new file mode 100644 index 0000000..84cbae3 --- /dev/null +++ b/network-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/network-build-logic/src/main/kotlin/android-app-convention.gradle.kts b/network-build-logic/src/main/kotlin/android-app-convention.gradle.kts new file mode 100644 index 0000000..2859874 --- /dev/null +++ b/network-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/network-build-logic/src/main/kotlin/android-base-convention.gradle.kts b/network-build-logic/src/main/kotlin/android-base-convention.gradle.kts new file mode 100644 index 0000000..7f67285 --- /dev/null +++ b/network-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/network-build-logic/src/main/kotlin/android-library-convention.gradle.kts b/network-build-logic/src/main/kotlin/android-library-convention.gradle.kts new file mode 100644 index 0000000..c435401 --- /dev/null +++ b/network-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/network-build-logic/src/main/kotlin/android-publication-convention.gradle.kts b/network-build-logic/src/main/kotlin/android-publication-convention.gradle.kts new file mode 100644 index 0000000..b4dae9e --- /dev/null +++ b/network-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/network-build-logic/src/main/kotlin/detekt-convention.gradle.kts b/network-build-logic/src/main/kotlin/detekt-convention.gradle.kts new file mode 100644 index 0000000..68343a8 --- /dev/null +++ b/network-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/network-build-logic/src/main/kotlin/javadoc-stub-convention.gradle.kts b/network-build-logic/src/main/kotlin/javadoc-stub-convention.gradle.kts new file mode 100644 index 0000000..a1a2691 --- /dev/null +++ b/network-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/network-build-logic/src/main/kotlin/multiplatform-library-convention.gradle.kts b/network-build-logic/src/main/kotlin/multiplatform-library-convention.gradle.kts new file mode 100644 index 0000000..f203934 --- /dev/null +++ b/network-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/network-build-logic/src/main/kotlin/publication-convention.gradle.kts b/network-build-logic/src/main/kotlin/publication-convention.gradle.kts new file mode 100644 index 0000000..3d13cf1 --- /dev/null +++ b/network-build-logic/src/main/kotlin/publication-convention.gradle.kts @@ -0,0 +1,74 @@ +/* + * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +import java.util.Base64 + +plugins { + 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 network") + description.set("Network components with codegeneration of rest api for mobile (android & ios) Kotlin Multiplatform development") + url.set("https://github.com/icerockdev/moko-network") + licenses { + license { + name.set("Apache-2.0") + distribution.set("repo") + url.set("https://github.com/icerockdev/moko-network/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") + } + developer { + id.set("Dorofeev") + name.set("Andrey Dorofeev") + email.set("adorofeev@icerockdev.com") + } + } + + scm { + connection.set("scm:git:ssh://github.com/icerockdev/moko-network.git") + developerConnection.set("scm:git:ssh://github.com/icerockdev/moko-network.git") + url.set("https://github.com/icerockdev/moko-network") + } + } + } +} + + +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/network-deps/build.gradle.kts b/network-deps/build.gradle.kts deleted file mode 100644 index fe256ef..0000000 --- a/network-deps/build.gradle.kts +++ /dev/null @@ -1,29 +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() - - gradlePluginPortal() - - 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") -} - -group = "gradle" -version = "1" diff --git a/network-deps/src/main/kotlin/Deps.kt b/network-deps/src/main/kotlin/Deps.kt deleted file mode 100755 index cfef99a..0000000 --- a/network-deps/src/main/kotlin/Deps.kt +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright 2019 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 lifecycleVersion = "2.2.0" - private const val glideVersion = "4.9.0" - private const val androidAppCompatVersion = "1.1.0" - private const val espressoCoreVersion = "3.2.0" - private const val testRunnerVersion = "1.2.0" - private const val testExtJunitVersion = "1.1.1" - private const val androidxTestVersion = "1.3.0" - private const val robolectricVersion = "4.3" - - private const val openApiGeneratorVersion = "5.1.0" - private const val guavaVersion = "30.1-jre" - private const val kotlinxSerializationVersion = "1.1.0" - private const val coroutinesVersion = "1.4.2-native-mt" - private const val ktorClientVersion = "1.5.2" - - private const val detektVersion = "1.15.0" - - private const val mokoResourcesVersion = "0.15.1" - private const val mokoMvvmVersion = "0.9.2" - private const val mokoErrorsVersion = "0.3.2" - private const val mokoTestVersion = "0.2.1" - const val mokoNetworkVersion = "0.15.2" - - private const val kbignumVersion = "2.0.6" - - object Android { - const val compileSdk = 30 - const val targetSdk = 30 - const val minSdk = 16 - } - - object Plugins { - val androidLibrary = GradlePlugin(id = "com.android.library") - val kotlinMultiplatform = GradlePlugin( - id = "org.jetbrains.kotlin.multiplatform", - module = "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" - ) - val kotlinKapt = GradlePlugin(id = "kotlin-kapt") - val kotlinSerialization = GradlePlugin( - id = "org.jetbrains.kotlin.plugin.serialization", - module = "org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion" - ) - val mavenPublish = GradlePlugin(id = "org.gradle.maven-publish") - - val mokoNetwork = GradlePlugin( - id = "dev.icerock.mobile.multiplatform-network-generator", - module = "dev.icerock.moko:network-generator:$mokoNetworkVersion" - ) - - val mokoResources = GradlePlugin( - id = "dev.icerock.mobile.multiplatform-resources", - module = "dev.icerock.moko:resources-generator:$mokoResourcesVersion" - ) - - val detekt = GradlePlugin( - id = "io.gitlab.arturbosch.detekt", - version = detektVersion - ) - } - - object Libs { - object Android { - const val appCompat = - "androidx.appcompat:appcompat:$androidAppCompatVersion" - val glide = - "com.github.bumptech.glide:glide:$glideVersion" - val lifecycle = - "androidx.lifecycle:lifecycle-extensions:$lifecycleVersion" - val ktorClientOkHttp = - "io.ktor:ktor-client-okhttp:$ktorClientVersion" - - const val mokoMvvmDataBinding = "dev.icerock.moko:mvvm-databinding:$mokoMvvmVersion" - - object Tests { - const val espressoCore = - "androidx.test.espresso:espresso-core:$espressoCoreVersion" - const val kotlinTestJUnit = - "org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion" - const val testCore = - "androidx.test:core:$androidxTestVersion" - const val robolectric = - "org.robolectric:robolectric:$robolectricVersion" - const val testRunner = - "androidx.test:runner:$testRunnerVersion" - const val testRules = - "androidx.test:rules:$testRunnerVersion" - const val testExtJunit = - "androidx.test.ext:junit:$testExtJunitVersion" - } - } - - object MultiPlatform { - const val kotlinSerialization = - "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinxSerializationVersion" - const val coroutines = - "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion" - const val ktorClient = - "io.ktor:ktor-client-core:$ktorClientVersion" - const val ktorClientLogging = - "io.ktor:ktor-client-logging:$ktorClientVersion" - const val ktorClientMock = - "io.ktor:ktor-client-mock:$ktorClientVersion" - const val mokoResources = - "dev.icerock.moko:resources:$mokoResourcesVersion" - const val mokoMvvmCore = - "dev.icerock.moko:mvvm-core:$mokoMvvmVersion" - const val mokoMvvmLiveData = - "dev.icerock.moko:mvvm-livedata:$mokoMvvmVersion" - const val mokoErrors = - "dev.icerock.moko:errors:$mokoErrorsVersion" - const val mokoNetwork = - "dev.icerock.moko:network:$mokoNetworkVersion" - const val mokoNetworkErrors = - "dev.icerock.moko:network-errors:$mokoNetworkVersion" - const val mokoNetworkBignum = - "dev.icerock.moko:network-bignum:$mokoNetworkVersion" - - const val kbignum = "com.soywiz.korlibs.kbignum:kbignum:$kbignumVersion" - - object Tests { - const val kotlinTest = - "org.jetbrains.kotlin:kotlin-test-common:$kotlinVersion" - const val kotlinTestAnnotations = - "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlinVersion" - const val mokoTest = "dev.icerock.moko:test:$mokoTestVersion" - } - } - - object Ios { - const val ktorClientIos = - "io.ktor:ktor-client-ios:$ktorClientVersion" - } - - object Jvm { - const val openApiGenerator = - "org.openapitools:openapi-generator-gradle-plugin:$openApiGeneratorVersion" - const val guava = - "com.google.guava:guava:$guavaVersion" - } - - object Detekt { - const val detektFormatting = - "io.gitlab.arturbosch.detekt:detekt-formatting:$detektVersion" - } - } -} diff --git a/network-errors/build.gradle.kts b/network-errors/build.gradle.kts index 3f6738a..37319ad 100644 --- a/network-errors/build.gradle.kts +++ b/network-errors/build.gradle.kts @@ -3,20 +3,20 @@ */ plugins { - id("com.android.library") - id("org.jetbrains.kotlin.multiplatform") - id("dev.icerock.mobile.multiplatform") + id("multiplatform-library-convention") + id("dev.icerock.mobile.multiplatform.android-manifest") id("dev.icerock.mobile.multiplatform-resources") - id("org.gradle.maven-publish") + id("publication-convention") + id("javadoc-stub-convention") } dependencies { - commonMainImplementation(Deps.Libs.MultiPlatform.kotlinSerialization) + commonMainImplementation(libs.kotlinSerialization) - commonMainApi(Deps.Libs.MultiPlatform.mokoErrors) - commonMainApi(Deps.Libs.MultiPlatform.mokoResources) + commonMainApi(libs.mokoErrors) + commonMainApi(libs.mokoResources) - commonMainImplementation(project(":network")) + commonMainImplementation(projects.network) } multiplatformResources { diff --git a/network-generator/build.gradle.kts b/network-generator/build.gradle.kts index 3e6a921..027fea6 100644 --- a/network-generator/build.gradle.kts +++ b/network-generator/build.gradle.kts @@ -2,34 +2,27 @@ * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. */ -import java.util.Base64 - plugins { - id("org.jetbrains.kotlin.jvm") version("1.4.31") - id("io.gitlab.arturbosch.detekt") version("1.15.0") - id("org.gradle.maven-publish") - id("signing") + id("org.jetbrains.kotlin.jvm") version("1.5.20") + id("detekt-convention") + id("publication-convention") + } buildscript { dependencies { classpath("org.jetbrains.kotlin:kotlin-serialization:1.4.31") - classpath("gradle:network-deps:1") } } group = "dev.icerock.moko" -version = Deps.mokoNetworkVersion +version = libs.versions.mokoNetworkVersion.get() dependencies { implementation(gradleKotlinDsl()) - - implementation(Deps.Libs.Jvm.guava) - implementation(Deps.Libs.Jvm.openApiGenerator) - - compileOnly(Deps.Plugins.kotlinMultiplatform.module!!) - - "detektPlugins"(Deps.Libs.Detekt.detektFormatting) + compileOnly(libs.kotlinGradlePlugin) + implementation(libs.guava) + implementation(libs.openApiGenerator) } java { @@ -39,64 +32,6 @@ java { withSourcesJar() } -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 { - register("mavenJava", MavenPublication::class) { - from(components["java"]) - pom { - name.set("MOKO network") - description.set("Network components with codegeneration of rest api for mobile (android & ios) Kotlin Multiplatform development") - url.set("https://github.com/icerockdev/moko-network") - licenses { - license { - url.set("https://github.com/icerockdev/moko-network/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") - } - developer { - id.set("Dorofeev") - name.set("Andrey Dorofeev") - email.set("adorofeev@icerockdev.com") - } - } - - scm { - connection.set("scm:git:ssh://github.com/icerockdev/moko-network.git") - developerConnection.set("scm:git:ssh://github.com/icerockdev/moko-network.git") - url.set("https://github.com/icerockdev/moko-network") - } - } - } - - 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) - } - } - } +tasks.withType().configureEach { + kotlinOptions.jvmTarget = "1.8" } diff --git a/network-generator/settings.gradle.kts b/network-generator/settings.gradle.kts index 73cb1c7..7276606 100644 --- a/network-generator/settings.gradle.kts +++ b/network-generator/settings.gradle.kts @@ -1,6 +1,7 @@ /* * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. */ +enableFeaturePreview("VERSION_CATALOGS") pluginManagement { repositories { @@ -22,6 +23,13 @@ dependencyResolutionManagement { } } } + + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } } -includeBuild("../network-deps") +includeBuild("../network-build-logic") + diff --git a/network/build.gradle.kts b/network/build.gradle.kts index f9e6611..a9eac80 100644 --- a/network/build.gradle.kts +++ b/network/build.gradle.kts @@ -3,39 +3,59 @@ */ plugins { - id("com.android.library") - id("org.jetbrains.kotlin.multiplatform") - id("dev.icerock.mobile.multiplatform") + id("multiplatform-library-convention") + id("dev.icerock.mobile.multiplatform.android-manifest") id("org.jetbrains.kotlin.plugin.serialization") - id("org.gradle.maven-publish") + id("publication-convention") + id("javadoc-stub-convention") } kotlin { + jvm() + sourceSets { - val iosArm64Main by getting - val iosX64Main by getting + val commonMain by getting + + val commonJvmAndroid = create("commonJvmAndroid") { + dependsOn(commonMain) + dependencies { + api(libs.ktorClientOkHttp) + } + } + + val androidMain by getting { + dependsOn(commonJvmAndroid) + } - iosArm64Main.dependsOn(iosX64Main) + val jvmMain by getting { + dependsOn(commonJvmAndroid) + dependencies { + api(libs.ktorClientOkHttp) + } + } + + val jvmTest by getting { + dependencies { + implementation(libs.kotlinTestJUnit) + } + } } } dependencies { - commonMainImplementation(Deps.Libs.MultiPlatform.coroutines) { - isForce = true - } - - commonMainApi(Deps.Libs.MultiPlatform.kotlinSerialization) - commonMainApi(Deps.Libs.MultiPlatform.ktorClient) - androidMainApi(Deps.Libs.Android.ktorClientOkHttp) - iosMainApi(Deps.Libs.Ios.ktorClientIos) + commonMainImplementation(libs.coroutines) + commonMainApi(libs.kotlinSerialization) + commonMainApi(libs.ktorClient) + androidMainApi(libs.ktorClientOkHttp) + iosMainApi(libs.ktorClientIos) - androidMainImplementation(Deps.Libs.Android.appCompat) + "androidMainImplementation"(libs.appCompat) - commonTestImplementation(Deps.Libs.MultiPlatform.ktorClientMock) - commonTestImplementation(Deps.Libs.MultiPlatform.Tests.kotlinTest) - commonTestImplementation(Deps.Libs.MultiPlatform.Tests.kotlinTestAnnotations) + commonTestImplementation(libs.ktorClientMock) + commonTestImplementation(libs.kotlinTest) + commonTestImplementation(libs.kotlinTestAnnotations) - androidTestImplementation(Deps.Libs.Android.Tests.kotlinTestJUnit) + "androidTestImplementation"(libs.kotlinTestJUnit) } tasks.named("publishToMavenLocal") { diff --git a/network/src/androidMain/kotlin/dev/icerock/moko/network/LanguageProvider.kt b/network/src/androidMain/kotlin/dev/icerock/moko/network/LanguageProvider.kt index 2ce1ded..67838a0 100644 --- a/network/src/androidMain/kotlin/dev/icerock/moko/network/LanguageProvider.kt +++ b/network/src/androidMain/kotlin/dev/icerock/moko/network/LanguageProvider.kt @@ -1,15 +1,15 @@ -/* - * Copyright 2020 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. - */ - -package dev.icerock.moko.network - -import android.content.res.Resources -import androidx.core.os.ConfigurationCompat -import dev.icerock.moko.network.features.LanguageFeature - -actual class LanguageProvider : LanguageFeature.LanguageCodeProvider { - override fun getLanguageCode(): String? { - return ConfigurationCompat.getLocales(Resources.getSystem().configuration).get(0).language - } -} +/* + * Copyright 2020 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +package dev.icerock.moko.network + +import android.content.res.Resources +import androidx.core.os.ConfigurationCompat +import dev.icerock.moko.network.features.LanguageFeature + +actual class LanguageProvider : LanguageFeature.LanguageCodeProvider { + override fun getLanguageCode(): String? { + return ConfigurationCompat.getLocales(Resources.getSystem().configuration).get(0).language + } +} diff --git a/network/src/androidMain/kotlin/dev/icerock/moko/network/GMTDateExt.kt b/network/src/commonJvmAndroid/kotlin/dev/icerock/moko/network/GMTDateExt.kt similarity index 100% rename from network/src/androidMain/kotlin/dev/icerock/moko/network/GMTDateExt.kt rename to network/src/commonJvmAndroid/kotlin/dev/icerock/moko/network/GMTDateExt.kt diff --git a/network/src/androidMain/kotlin/dev/icerock/moko/network/ParserUtils.kt b/network/src/commonJvmAndroid/kotlin/dev/icerock/moko/network/ParserUtils.kt similarity index 100% rename from network/src/androidMain/kotlin/dev/icerock/moko/network/ParserUtils.kt rename to network/src/commonJvmAndroid/kotlin/dev/icerock/moko/network/ParserUtils.kt diff --git a/network/src/androidMain/kotlin/dev/icerock/moko/network/createHttpClientEngine.kt b/network/src/commonJvmAndroid/kotlin/dev/icerock/moko/network/createHttpClientEngine.kt similarity index 100% rename from network/src/androidMain/kotlin/dev/icerock/moko/network/createHttpClientEngine.kt rename to network/src/commonJvmAndroid/kotlin/dev/icerock/moko/network/createHttpClientEngine.kt diff --git a/network/src/androidMain/kotlin/dev/icerock/moko/network/isNetworkConnectionError.kt b/network/src/commonJvmAndroid/kotlin/dev/icerock/moko/network/isNetworkConnectionError.kt similarity index 100% rename from network/src/androidMain/kotlin/dev/icerock/moko/network/isNetworkConnectionError.kt rename to network/src/commonJvmAndroid/kotlin/dev/icerock/moko/network/isNetworkConnectionError.kt diff --git a/network/src/androidMain/kotlin/dev/icerock/moko/network/isSSLException.kt b/network/src/commonJvmAndroid/kotlin/dev/icerock/moko/network/isSSLException.kt similarity index 100% rename from network/src/androidMain/kotlin/dev/icerock/moko/network/isSSLException.kt rename to network/src/commonJvmAndroid/kotlin/dev/icerock/moko/network/isSSLException.kt diff --git a/network/src/iosArm64Main b/network/src/iosArm64Main new file mode 120000 index 0000000..46be4b8 --- /dev/null +++ b/network/src/iosArm64Main @@ -0,0 +1 @@ +iosX64Main \ No newline at end of file diff --git a/network/src/jvmMain/kotlin/dev/icerock/moko/network/LanguageProvider.kt b/network/src/jvmMain/kotlin/dev/icerock/moko/network/LanguageProvider.kt new file mode 100644 index 0000000..e610310 --- /dev/null +++ b/network/src/jvmMain/kotlin/dev/icerock/moko/network/LanguageProvider.kt @@ -0,0 +1,10 @@ +package dev.icerock.moko.network + +import dev.icerock.moko.network.features.LanguageFeature +import java.util.Locale + +actual class LanguageProvider : LanguageFeature.LanguageCodeProvider { + override fun getLanguageCode(): String? { + return Locale.getDefault().displayLanguage + } +} diff --git a/sample/android-app/build.gradle.kts b/sample/android-app/build.gradle.kts index 18d1320..d05faa6 100644 --- a/sample/android-app/build.gradle.kts +++ b/sample/android-app/build.gradle.kts @@ -3,51 +3,25 @@ */ plugins { - id("com.android.application") - id("kotlin-android") + id("android-app-convention") + id("detekt-convention") id("kotlin-kapt") } 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.network" versionCode = 1 versionName = "0.1.0" - - vectorDrawables.useSupportLibrary = true - } - - 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.mokoMvvmDataBinding) + implementation(libs.appCompat) + implementation(libs.mokoMvvmDataBinding) - implementation(project(":sample:mpp-library")) + implementation(projects.sample.mppLibrary) } diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts deleted file mode 100644 index d9a3449..0000000 --- a/sample/build.gradle.kts +++ /dev/null @@ -1,16 +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.mokoNetwork)) - .with(project(":network")) - substitute(module(Deps.Libs.MultiPlatform.mokoNetworkErrors)) - .with(project(":network-errors")) - substitute(module(Deps.Libs.MultiPlatform.mokoNetworkBignum)) - .with(project(":network-bignum")) - } - } -} diff --git a/sample/mpp-library/build.gradle.kts b/sample/mpp-library/build.gradle.kts index 3565068..fd602c6 100644 --- a/sample/mpp-library/build.gradle.kts +++ b/sample/mpp-library/build.gradle.kts @@ -4,35 +4,46 @@ plugins { id("com.android.library") + id("android-base-convention") + id("detekt-convention") id("org.jetbrains.kotlin.multiplatform") id("org.jetbrains.kotlin.plugin.serialization") - id("dev.icerock.mobile.multiplatform") id("dev.icerock.mobile.multiplatform-resources") id("dev.icerock.mobile.multiplatform-network-generator") + id("dev.icerock.mobile.multiplatform.android-manifest") id("dev.icerock.mobile.multiplatform.ios-framework") } +kotlin { + android() + ios() +} + dependencies { - commonMainImplementation(Deps.Libs.MultiPlatform.coroutines) - commonMainImplementation(Deps.Libs.MultiPlatform.ktorClient) - commonMainImplementation(Deps.Libs.MultiPlatform.ktorClientLogging) - commonMainImplementation(Deps.Libs.MultiPlatform.kotlinSerialization) - commonMainImplementation(Deps.Libs.MultiPlatform.kbignum) + commonMainImplementation(libs.coroutines) + commonMainImplementation(libs.ktorClient) + commonMainImplementation(libs.ktorClientLogging) + commonMainImplementation(libs.kotlinSerialization) + commonMainImplementation(libs.kbignum) + + commonMainApi(libs.mokoMvvmCore) + commonMainApi(libs.mokoMvvmLiveData) + commonMainApi(libs.mokoNetwork) + commonMainApi(libs.mokoNetworkErrors) + commonMainApi(libs.mokoNetworkBignum) - commonMainApi(Deps.Libs.MultiPlatform.mokoMvvmCore) - commonMainApi(Deps.Libs.MultiPlatform.mokoMvvmLiveData) - commonMainApi(Deps.Libs.MultiPlatform.mokoNetwork) - commonMainApi(Deps.Libs.MultiPlatform.mokoNetworkErrors) - commonMainApi(Deps.Libs.MultiPlatform.mokoNetworkBignum) + commonMainApi(projects.network) + commonMainApi(projects.networkBignum) + commonMainApi(projects.networkErrors) - androidMainImplementation(Deps.Libs.Android.lifecycle) + "androidMainImplementation"(libs.lifecycle) - commonTestImplementation(Deps.Libs.MultiPlatform.ktorClientMock) - commonTestImplementation(Deps.Libs.MultiPlatform.Tests.kotlinTest) - commonTestImplementation(Deps.Libs.MultiPlatform.Tests.mokoTest) - commonTestImplementation(Deps.Libs.MultiPlatform.Tests.kotlinTestAnnotations) + commonTestImplementation(libs.ktorClientMock) + commonTestImplementation(libs.kotlinTest) + commonTestImplementation(libs.mokoTest) + commonTestImplementation(libs.kotlinTestAnnotations) - androidTestImplementation(Deps.Libs.Android.Tests.kotlinTestJUnit) + androidTestImplementation(libs.kotlinTestJUnit) } multiplatformResources { diff --git a/settings.gradle.kts b/settings.gradle.kts index b47cf79..a396467 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,14 +2,8 @@ * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. */ -pluginManagement { - repositories { - mavenCentral() - google() - - gradlePluginPortal() - } -} +enableFeaturePreview("VERSION_CATALOGS") +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") dependencyResolutionManagement { repositories { @@ -18,14 +12,12 @@ dependencyResolutionManagement { jcenter { content { - includeGroup("org.jetbrains.trove4j") includeGroup("org.jetbrains.kotlinx") } } } } - -includeBuild("network-deps") +includeBuild("network-build-logic") includeBuild("network-generator") include(":network")