From 1a64c541f61f890e7c93520ceb0dc8593ae01b2d Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Wed, 16 Jun 2021 16:47:55 +0700 Subject: [PATCH 01/20] #138 gradle help complited successful --- build.gradle.kts | 28 +++++++---- gradle.properties | 2 + gradle/libs.versions.toml | 61 ++++++++++++++++++++++++ gradle/wrapper/gradle-wrapper.properties | 2 +- network-bignum/build.gradle.kts | 6 +-- network-deps/build.gradle.kts | 5 -- network-deps/src/main/kotlin/Deps.kt | 0 network-errors/build.gradle.kts | 8 ++-- network-generator/build.gradle.kts | 2 +- network/build.gradle.kts | 20 ++++---- sample/android-app/build.gradle.kts | 12 ++--- sample/build.gradle.kts | 16 ------- sample/mpp-library/build.gradle.kts | 41 +++++++++------- settings.gradle.kts | 30 ++++-------- 14 files changed, 139 insertions(+), 94 deletions(-) create mode 100644 gradle/libs.versions.toml mode change 100755 => 100644 network-deps/src/main/kotlin/Deps.kt delete mode 100644 sample/build.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts index 8e3482e..814b493 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,36 +17,44 @@ buildscript { dependencies { classpath("dev.icerock.moko:resources-generator:0.15.1") 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.10") + classpath("dev.icerock:mobile-multiplatform:0.9.2") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10") + classpath("com.android.tools.build:gradle:4.2.1") } } allprojects { - apply(plugin = Deps.Plugins.detekt.id) + repositories { + mavenCentral() + google() + } + + apply(plugin = "io.gitlab.arturbosch.detekt") configure { input.setFrom("src/commonMain/kotlin", "src/androidMain/kotlin", "src/iosMain/kotlin") } dependencies { - "detektPlugins"(Deps.Libs.Detekt.detektFormatting) + //"detektPlugins"(libs.detektFormatting.get()) + "detektPlugins"("io.gitlab.arturbosch.detekt:detekt-formatting:1.15.0") } - plugins.withId(Deps.Plugins.androidLibrary.id) { + plugins.withId("com.android.library") { configure { - compileSdkVersion(Deps.Android.compileSdk) + compileSdkVersion(libs.versions.compileSdk.get().toInt()) defaultConfig { - minSdkVersion(Deps.Android.minSdk) - targetSdkVersion(Deps.Android.targetSdk) + minSdkVersion(libs.versions.minSdk.get().toInt()) + targetSdkVersion(libs.versions.targetSdk.get().toInt()) } } } - plugins.withId(Deps.Plugins.mavenPublish.id) { + plugins.withId("org.gradle.maven-publish") { group = "dev.icerock.moko" - version = Deps.mokoNetworkVersion + version = libs.versions.mokoNetworkVersion.get() val javadocJar by tasks.registering(Jar::class) { archiveClassifier.set("javadoc") 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..e48371a --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,61 @@ +[versions] +kotlinVersion = "1.5.10" + +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.4.2-native-mt" +ktorClientVersion = "1.5.2" +detektVersion = "1.15.0" +mokoResourcesVersion = "0.15.1" +mokoMvvmVersion = "0.10.1" +mokoErrorsVersion = "0.3.3" +mokoTestVersion = "0.2.1" +mokoNetworkVersion = "0.15.2" +kbignumVersion = "2.0.6" + +compileSdk = "30" +targetSdk = "30" +minSdk = "16" + +[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", version.ref = "mokoTestVersion" } +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" } +detektFormatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detektVersion" } 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..27e023c 100644 --- a/network-bignum/build.gradle.kts +++ b/network-bignum/build.gradle.kts @@ -10,8 +10,8 @@ plugins { } 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-deps/build.gradle.kts b/network-deps/build.gradle.kts index fe256ef..055ee17 100644 --- a/network-deps/build.gradle.kts +++ b/network-deps/build.gradle.kts @@ -12,11 +12,6 @@ repositories { gradlePluginPortal() - jcenter { - content { - includeGroup("org.jetbrains.trove4j") - } - } } dependencies { diff --git a/network-deps/src/main/kotlin/Deps.kt b/network-deps/src/main/kotlin/Deps.kt old mode 100755 new mode 100644 diff --git a/network-errors/build.gradle.kts b/network-errors/build.gradle.kts index 3f6738a..8b89d26 100644 --- a/network-errors/build.gradle.kts +++ b/network-errors/build.gradle.kts @@ -11,12 +11,12 @@ plugins { } 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..9f5123c 100644 --- a/network-generator/build.gradle.kts +++ b/network-generator/build.gradle.kts @@ -5,7 +5,7 @@ import java.util.Base64 plugins { - id("org.jetbrains.kotlin.jvm") version("1.4.31") + id("org.jetbrains.kotlin.jvm") version("1.5.10") id("io.gitlab.arturbosch.detekt") version("1.15.0") id("org.gradle.maven-publish") id("signing") diff --git a/network/build.gradle.kts b/network/build.gradle.kts index f9e6611..bedd143 100644 --- a/network/build.gradle.kts +++ b/network/build.gradle.kts @@ -20,22 +20,22 @@ kotlin { } dependencies { - commonMainImplementation(Deps.Libs.MultiPlatform.coroutines) { + commonMainImplementation(libs.coroutines) { isForce = true } - commonMainApi(Deps.Libs.MultiPlatform.kotlinSerialization) - commonMainApi(Deps.Libs.MultiPlatform.ktorClient) - androidMainApi(Deps.Libs.Android.ktorClientOkHttp) - iosMainApi(Deps.Libs.Ios.ktorClientIos) + 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/sample/android-app/build.gradle.kts b/sample/android-app/build.gradle.kts index 18d1320..ed527b4 100644 --- a/sample/android-app/build.gradle.kts +++ b/sample/android-app/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } android { - compileSdkVersion(Deps.Android.compileSdk) + compileSdkVersion(libs.versions.compileSdk.get().toInt()) buildFeatures.dataBinding = true @@ -18,8 +18,8 @@ android { } defaultConfig { - minSdkVersion(Deps.Android.minSdk) - targetSdkVersion(Deps.Android.targetSdk) + minSdkVersion(libs.versions.minSdk.get().toInt()) + targetSdkVersion(libs.versions.targetSdk.get().toInt()) applicationId = "dev.icerock.moko.samples.network" @@ -46,8 +46,8 @@ android { } 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..6e9e834 100644 --- a/sample/mpp-library/build.gradle.kts +++ b/sample/mpp-library/build.gradle.kts @@ -12,27 +12,36 @@ plugins { id("dev.icerock.mobile.multiplatform.ios-framework") } +kotlin { + macosX64() + targets.withType(org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget::class.java).all { + binaries.withType(org.jetbrains.kotlin.gradle.plugin.mpp.Framework::class.java).all { + export(projects.network) + } + } +} + 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(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(libs.mokoMvvmCore) + commonMainApi(libs.mokoMvvmLiveData) + commonMainApi(libs.mokoNetwork) + commonMainApi(libs.mokoNetworkErrors) + commonMainApi(libs.mokoNetworkBignum) - 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..3731508 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,28 +2,14 @@ * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. */ -pluginManagement { - repositories { - mavenCentral() - google() - - gradlePluginPortal() - } -} - -dependencyResolutionManagement { - repositories { - mavenCentral() - google() - - jcenter { - content { - includeGroup("org.jetbrains.trove4j") - includeGroup("org.jetbrains.kotlinx") - } - } - } -} + + + + + + +enableFeaturePreview("VERSION_CATALOGS") +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") includeBuild("network-deps") includeBuild("network-generator") From a3363935ac5430c669d1a98f4fc27dc28e8ca31d Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Wed, 16 Jun 2021 17:38:56 +0700 Subject: [PATCH 02/20] #138 gradle sync successful --- sample/mpp-library/build.gradle.kts | 8 -------- settings.gradle.kts | 29 +++++++++++++++++++++++------ 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/sample/mpp-library/build.gradle.kts b/sample/mpp-library/build.gradle.kts index 6e9e834..658ab9b 100644 --- a/sample/mpp-library/build.gradle.kts +++ b/sample/mpp-library/build.gradle.kts @@ -12,14 +12,6 @@ plugins { id("dev.icerock.mobile.multiplatform.ios-framework") } -kotlin { - macosX64() - targets.withType(org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget::class.java).all { - binaries.withType(org.jetbrains.kotlin.gradle.plugin.mpp.Framework::class.java).all { - export(projects.network) - } - } -} dependencies { commonMainImplementation(libs.coroutines) diff --git a/settings.gradle.kts b/settings.gradle.kts index 3731508..3419f86 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,15 +2,32 @@ * 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") +pluginManagement { + repositories { + mavenCentral() + google() + + gradlePluginPortal() + } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + google() + + jcenter { + content { + includeGroup("org.jetbrains.trove4j") + includeGroup("org.jetbrains.kotlinx") + } + } + } +} + includeBuild("network-deps") includeBuild("network-generator") From d648bf468c906e3f6de9dc4c1beb40adfaf6598a Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Wed, 16 Jun 2021 17:41:09 +0700 Subject: [PATCH 03/20] #138 fixes --- build.gradle.kts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 814b493..4f9b8c8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -25,10 +25,6 @@ buildscript { } allprojects { - repositories { - mavenCentral() - google() - } apply(plugin = "io.gitlab.arturbosch.detekt") From 0491e183dd34ee4223ce5b702eb737d65764065a Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Wed, 16 Jun 2021 18:24:40 +0700 Subject: [PATCH 04/20] #138 removed deps and add path to libs.versions.toml for network-generator --- network-deps/build.gradle.kts | 24 ---- network-deps/src/main/kotlin/Deps.kt | 154 -------------------------- network-generator/build.gradle.kts | 12 +- network-generator/settings.gradle.kts | 7 +- settings.gradle.kts | 1 - 5 files changed, 12 insertions(+), 186 deletions(-) delete mode 100644 network-deps/build.gradle.kts delete mode 100644 network-deps/src/main/kotlin/Deps.kt diff --git a/network-deps/build.gradle.kts b/network-deps/build.gradle.kts deleted file mode 100644 index 055ee17..0000000 --- a/network-deps/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() - - gradlePluginPortal() - -} - -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 100644 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-generator/build.gradle.kts b/network-generator/build.gradle.kts index 9f5123c..b9ad1c6 100644 --- a/network-generator/build.gradle.kts +++ b/network-generator/build.gradle.kts @@ -14,22 +14,22 @@ plugins { 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) + implementation(libs.guava) + implementation(libs.openApiGenerator) - compileOnly(Deps.Plugins.kotlinMultiplatform.module!!) + compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10") - "detektPlugins"(Deps.Libs.Detekt.detektFormatting) + //"detektPlugins"(libs.detektFormatting) + "detektPlugins"("io.gitlab.arturbosch.detekt:detekt-formatting:1.15.0") } java { diff --git a/network-generator/settings.gradle.kts b/network-generator/settings.gradle.kts index 73cb1c7..1cbb705 100644 --- a/network-generator/settings.gradle.kts +++ b/network-generator/settings.gradle.kts @@ -22,6 +22,11 @@ dependencyResolutionManagement { } } } + + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } } -includeBuild("../network-deps") diff --git a/settings.gradle.kts b/settings.gradle.kts index 3419f86..5514ec2 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -28,7 +28,6 @@ dependencyResolutionManagement { } } -includeBuild("network-deps") includeBuild("network-generator") include(":network") From 212d2ce609d0b110148b1a84c23c0b1ff53cfae7 Mon Sep 17 00:00:00 2001 From: Simon Naumov Date: Wed, 16 Jun 2021 23:29:11 +0300 Subject: [PATCH 05/20] Adding JVM support --- build.gradle.kts | 2 +- network-deps/src/main/kotlin/Deps.kt | 12 +++++-- network/build.gradle.kts | 32 +++++++++++++++++-- .../icerock/moko/network/LanguageProvider.kt | 30 ++++++++--------- .../dev/icerock/moko/network/GMTDateExt.kt | 0 .../dev/icerock/moko/network/ParserUtils.kt | 0 .../moko/network/createHttpClientEngine.kt | 0 .../moko/network/isNetworkConnectionError.kt | 0 .../icerock/moko/network/isSSLException.kt | 0 .../icerock/moko/network/LanguageProvider.kt | 10 ++++++ sample/mpp-library/build.gradle.kts | 2 +- 11 files changed, 67 insertions(+), 21 deletions(-) rename network/src/{androidMain => commonJvmAndroid}/kotlin/dev/icerock/moko/network/GMTDateExt.kt (100%) rename network/src/{androidMain => commonJvmAndroid}/kotlin/dev/icerock/moko/network/ParserUtils.kt (100%) rename network/src/{androidMain => commonJvmAndroid}/kotlin/dev/icerock/moko/network/createHttpClientEngine.kt (100%) rename network/src/{androidMain => commonJvmAndroid}/kotlin/dev/icerock/moko/network/isNetworkConnectionError.kt (100%) rename network/src/{androidMain => commonJvmAndroid}/kotlin/dev/icerock/moko/network/isSSLException.kt (100%) create mode 100644 network/src/jvmMain/kotlin/dev/icerock/moko/network/LanguageProvider.kt diff --git a/build.gradle.kts b/build.gradle.kts index 8e3482e..e8c6f8b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,7 +26,7 @@ allprojects { apply(plugin = Deps.Plugins.detekt.id) configure { - input.setFrom("src/commonMain/kotlin", "src/androidMain/kotlin", "src/iosMain/kotlin") + input.setFrom("src/commonMain/kotlin", "src/androidMain/kotlin", "src/iosMain/kotlin", "src/jvmMain/kotlin") } dependencies { diff --git a/network-deps/src/main/kotlin/Deps.kt b/network-deps/src/main/kotlin/Deps.kt index cfef99a..52f2d5a 100755 --- a/network-deps/src/main/kotlin/Deps.kt +++ b/network-deps/src/main/kotlin/Deps.kt @@ -82,8 +82,6 @@ object Deps { 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 = @@ -146,6 +144,16 @@ object Deps { "com.google.guava:guava:$guavaVersion" } + object JvmAndroid { + val ktorClientOkHttp = + "io.ktor:ktor-client-okhttp:$ktorClientVersion" + + object Tests { + const val kotlinTestJUnit = + "org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion" + } + } + object Detekt { const val detektFormatting = "io.gitlab.arturbosch.detekt:detekt-formatting:$detektVersion" diff --git a/network/build.gradle.kts b/network/build.gradle.kts index f9e6611..743b8d5 100644 --- a/network/build.gradle.kts +++ b/network/build.gradle.kts @@ -11,7 +11,35 @@ plugins { } kotlin { + jvm() + sourceSets { + val commonMain by getting + + val commonJvmAndroid = create("commonJvmAndroid") { + dependsOn(commonMain) + dependencies { + api(Deps.Libs.JvmAndroid.ktorClientOkHttp) + } + } + + val androidMain by getting { + dependsOn(commonJvmAndroid) + } + + val jvmMain by getting { + dependsOn(commonJvmAndroid) + dependencies { + api(Deps.Libs.JvmAndroid.ktorClientOkHttp) + } + } + + val jvmTest by getting { + dependencies { + implementation(Deps.Libs.JvmAndroid.Tests.kotlinTestJUnit) + } + } + val iosArm64Main by getting val iosX64Main by getting @@ -26,7 +54,7 @@ dependencies { commonMainApi(Deps.Libs.MultiPlatform.kotlinSerialization) commonMainApi(Deps.Libs.MultiPlatform.ktorClient) - androidMainApi(Deps.Libs.Android.ktorClientOkHttp) + androidMainApi(Deps.Libs.JvmAndroid.ktorClientOkHttp) iosMainApi(Deps.Libs.Ios.ktorClientIos) androidMainImplementation(Deps.Libs.Android.appCompat) @@ -35,7 +63,7 @@ dependencies { commonTestImplementation(Deps.Libs.MultiPlatform.Tests.kotlinTest) commonTestImplementation(Deps.Libs.MultiPlatform.Tests.kotlinTestAnnotations) - androidTestImplementation(Deps.Libs.Android.Tests.kotlinTestJUnit) + androidTestImplementation(Deps.Libs.JvmAndroid.Tests.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/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/mpp-library/build.gradle.kts b/sample/mpp-library/build.gradle.kts index 3565068..7d5462a 100644 --- a/sample/mpp-library/build.gradle.kts +++ b/sample/mpp-library/build.gradle.kts @@ -32,7 +32,7 @@ dependencies { commonTestImplementation(Deps.Libs.MultiPlatform.Tests.mokoTest) commonTestImplementation(Deps.Libs.MultiPlatform.Tests.kotlinTestAnnotations) - androidTestImplementation(Deps.Libs.Android.Tests.kotlinTestJUnit) + androidTestImplementation(Deps.Libs.JvmAndroid.Tests.kotlinTestJUnit) } multiplatformResources { From e0e60bb06298e070ba63f47c290fa96be57579cd Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Thu, 17 Jun 2021 11:26:13 +0700 Subject: [PATCH 06/20] #138 updated moko-test version --- gradle/libs.versions.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e48371a..1c79dbc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -18,7 +18,7 @@ detektVersion = "1.15.0" mokoResourcesVersion = "0.15.1" mokoMvvmVersion = "0.10.1" mokoErrorsVersion = "0.3.3" -mokoTestVersion = "0.2.1" +mokoTestVersion = "0.3.0" mokoNetworkVersion = "0.15.2" kbignumVersion = "2.0.6" @@ -54,7 +54,7 @@ mokoNetworkBignum = { module = "dev.icerock.moko:network-bignum", version.ref = 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", version.ref = "mokoTestVersion" } +mokoTest = { module = "dev.icerock.moko:test-core", version.ref = "mokoTestVersion" } 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" } From f150105f77903a595f92d34519fa65b1157ac8d0 Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Thu, 17 Jun 2021 11:27:56 +0700 Subject: [PATCH 07/20] #138 used native-mt version permanently --- build.gradle.kts | 6 ++++++ network/build.gradle.kts | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4f9b8c8..4b0a01a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -37,6 +37,12 @@ allprojects { "detektPlugins"("io.gitlab.arturbosch.detekt:detekt-formatting:1.15.0") } + configurations.configureEach { + resolutionStrategy { + force("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2-native-mt") + } + } + plugins.withId("com.android.library") { configure { compileSdkVersion(libs.versions.compileSdk.get().toInt()) diff --git a/network/build.gradle.kts b/network/build.gradle.kts index bedd143..9cedbe8 100644 --- a/network/build.gradle.kts +++ b/network/build.gradle.kts @@ -20,9 +20,6 @@ kotlin { } dependencies { - commonMainImplementation(libs.coroutines) { - isForce = true - } commonMainApi(libs.kotlinSerialization) commonMainApi(libs.ktorClient) From 35cc359265700f85917dbe1ce0469adac9fcadde Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Thu, 17 Jun 2021 11:52:25 +0700 Subject: [PATCH 08/20] #138 readme changes and version update --- README.md | 38 ++------------------------------------ gradle/libs.versions.toml | 2 +- 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index eee6a22..6949b5c 100755 --- a/README.md +++ b/README.md @@ -1,5 +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://img.shields.io/badge/kotlin-1.5.10-orange) # Mobile Kotlin network components This is a Kotlin MultiPlatform library that provide network components for iOS & Android. Library is @@ -28,40 +28,6 @@ This is a Kotlin MultiPlatform library that provide network components for iOS & - 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 - ## Installation root build.gradle ```groovy @@ -88,7 +54,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/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1c79dbc..5cf91c1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -19,7 +19,7 @@ mokoResourcesVersion = "0.15.1" mokoMvvmVersion = "0.10.1" mokoErrorsVersion = "0.3.3" mokoTestVersion = "0.3.0" -mokoNetworkVersion = "0.15.2" +mokoNetworkVersion = "0.16.0" kbignumVersion = "2.0.6" compileSdk = "30" From 9da67b295e5f5d16949b6cee6c45ed0574c02670 Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Thu, 17 Jun 2021 12:21:38 +0700 Subject: [PATCH 09/20] #138 fixes --- network-generator/settings.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/network-generator/settings.gradle.kts b/network-generator/settings.gradle.kts index 1cbb705..1be7afc 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 { From c0c7bb74e85a013dd90e936f620d5ba64f4ba6be Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Thu, 17 Jun 2021 12:45:20 +0700 Subject: [PATCH 10/20] #138 local included projects while they aren't published anywhere --- sample/mpp-library/build.gradle.kts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sample/mpp-library/build.gradle.kts b/sample/mpp-library/build.gradle.kts index 658ab9b..9c38962 100644 --- a/sample/mpp-library/build.gradle.kts +++ b/sample/mpp-library/build.gradle.kts @@ -26,6 +26,10 @@ dependencies { commonMainApi(libs.mokoNetworkErrors) commonMainApi(libs.mokoNetworkBignum) + commonMainApi(projects.network) + commonMainApi(projects.networkBignum) + commonMainApi(projects.networkErrors) + "androidMainImplementation"(libs.lifecycle) commonTestImplementation(libs.ktorClientMock) From 5a17669455f6b530dc8ae7cabfc2def1e259ab7f Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Thu, 17 Jun 2021 15:19:58 +0700 Subject: [PATCH 11/20] #138 fixes --- build.gradle.kts | 5 ++--- network-generator/build.gradle.kts | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4b0a01a..418e8cf 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -33,13 +33,12 @@ allprojects { } dependencies { - //"detektPlugins"(libs.detektFormatting.get()) - "detektPlugins"("io.gitlab.arturbosch.detekt:detekt-formatting:1.15.0") + "detektPlugins"(rootProject.libs.detektFormatting) } configurations.configureEach { resolutionStrategy { - force("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2-native-mt") + force("${rootProject.libs.coroutines.get().module}:${rootProject.libs.coroutines.get().versionConstraint}") } } diff --git a/network-generator/build.gradle.kts b/network-generator/build.gradle.kts index b9ad1c6..2ebed1c 100644 --- a/network-generator/build.gradle.kts +++ b/network-generator/build.gradle.kts @@ -28,8 +28,7 @@ dependencies { compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10") - //"detektPlugins"(libs.detektFormatting) - "detektPlugins"("io.gitlab.arturbosch.detekt:detekt-formatting:1.15.0") + "detektPlugins"(rootProject.libs.detektFormatting) } java { From 463b9c2b0b638ece39ed0877511354f1306edc65 Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Thu, 17 Jun 2021 17:26:03 +0700 Subject: [PATCH 12/20] #138 update version --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 418e8cf..4cf7b35 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -18,7 +18,7 @@ buildscript { classpath("dev.icerock.moko:resources-generator:0.15.1") classpath("dev.icerock.moko:network-generator") // substituted classpath("org.jetbrains.kotlin:kotlin-serialization:1.5.10") - classpath("dev.icerock:mobile-multiplatform:0.9.2") + classpath("dev.icerock:mobile-multiplatform:0.10.0") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10") classpath("com.android.tools.build:gradle:4.2.1") } From cec459270edb6ce862ff9507776f2122c0192a34 Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Thu, 17 Jun 2021 17:38:07 +0700 Subject: [PATCH 13/20] #138 fixes --- network/build.gradle.kts | 2 +- sample/mpp-library/build.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/network/build.gradle.kts b/network/build.gradle.kts index 9cedbe8..d6ae782 100644 --- a/network/build.gradle.kts +++ b/network/build.gradle.kts @@ -26,7 +26,7 @@ dependencies { androidMainApi(libs.ktorClientOkHttp) iosMainApi(libs.ktorClientIos) - "androidMainImplementation"(libs.appCompat) + androidMainImplementation(libs.appCompat) commonTestImplementation(libs.ktorClientMock) commonTestImplementation(libs.kotlinTest) diff --git a/sample/mpp-library/build.gradle.kts b/sample/mpp-library/build.gradle.kts index 9c38962..9f5631b 100644 --- a/sample/mpp-library/build.gradle.kts +++ b/sample/mpp-library/build.gradle.kts @@ -30,7 +30,7 @@ dependencies { commonMainApi(projects.networkBignum) commonMainApi(projects.networkErrors) - "androidMainImplementation"(libs.lifecycle) + androidMainImplementation(libs.lifecycle) commonTestImplementation(libs.ktorClientMock) commonTestImplementation(libs.kotlinTest) From 67bc11de4de68e52989d74fa980d2216edb2993a Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Mon, 28 Jun 2021 18:50:11 +0700 Subject: [PATCH 14/20] =?UTF-8?q?#138=20temp=20commit=20use=20=D1=81onvent?= =?UTF-8?q?ion=20plugin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/compilation-check.yml | 10 +- .github/workflows/publish.yml | 8 +- README.md | 9 +- build.gradle.kts | 112 ++---------------- gradle/libs.versions.toml | 18 ++- network-bignum/build.gradle.kts | 7 +- network-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 | 65 ++++++++++ network-errors/build.gradle.kts | 7 +- network-generator/build.gradle.kts | 4 +- network/build.gradle.kts | 16 +-- network/src/iosArm64Main | 1 + sample/android-app/build.gradle.kts | 30 +---- sample/mpp-library/build.gradle.kts | 10 +- settings.gradle.kts | 12 +- 22 files changed, 255 insertions(+), 193 deletions(-) create mode 100644 network-build-logic/build.gradle.kts create mode 100644 network-build-logic/src/main/kotlin/android-app-convention.gradle.kts create mode 100644 network-build-logic/src/main/kotlin/android-base-convention.gradle.kts create mode 100644 network-build-logic/src/main/kotlin/android-library-convention.gradle.kts create mode 100644 network-build-logic/src/main/kotlin/android-publication-convention.gradle.kts create mode 100644 network-build-logic/src/main/kotlin/detekt-convention.gradle.kts create mode 100644 network-build-logic/src/main/kotlin/javadoc-stub-convention.gradle.kts create mode 100644 network-build-logic/src/main/kotlin/multiplatform-library-convention.gradle.kts create mode 100644 network-build-logic/src/main/kotlin/publication-convention.gradle.kts create mode 120000 network/src/iosArm64Main 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 6949b5c..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.5.10-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,9 +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+ +- iOS version 11.0+ ## Installation root build.gradle @@ -37,7 +36,7 @@ buildscript { } dependencies { - classpath "dev.icerock.moko:network-generator:0.15.2" + classpath "dev.icerock.moko:network-generator:0.16.0" } } diff --git a/build.gradle.kts b/build.gradle.kts index 423d28c..bcaea83 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,10 +4,6 @@ import java.util.Base64 -plugins { - id("io.gitlab.arturbosch.detekt") version("1.15.0") apply(false) -} - buildscript { repositories { mavenCentral() @@ -15,118 +11,24 @@ 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.5.10") - classpath("dev.icerock:mobile-multiplatform:0.10.0") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10") - classpath("com.android.tools.build:gradle:4.2.1") + classpath("org.jetbrains.kotlin:kotlin-serialization:1.5.20") + + classpath(":network-build-logic") } } allprojects { - - apply(plugin = "io.gitlab.arturbosch.detekt") - - configure { - input.setFrom("src/commonMain/kotlin", "src/androidMain/kotlin", "src/iosMain/kotlin", "src/jvmMain/kotlin") - } - - dependencies { - "detektPlugins"(rootProject.libs.detektFormatting) + plugins.withId("org.gradle.maven-publish") { + group = "dev.icerock.moko" + version = libs.versions.mokoNetworkVersion.get() } - configurations.configureEach { resolutionStrategy { force("${rootProject.libs.coroutines.get().module}:${rootProject.libs.coroutines.get().versionConstraint}") } } - - plugins.withId("com.android.library") { - configure { - compileSdkVersion(libs.versions.compileSdk.get().toInt()) - - defaultConfig { - minSdkVersion(libs.versions.minSdk.get().toInt()) - targetSdkVersion(libs.versions.targetSdk.get().toInt()) - } - } - } - - plugins.withId("org.gradle.maven-publish") { - group = "dev.icerock.moko" - version = libs.versions.mokoNetworkVersion.get() - - 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) - } - } - } - } } tasks.register("clean", Delete::class).configure { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5cf91c1..7c44247 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -kotlinVersion = "1.5.10" +kotlinVersion = "1.5.20" lifecycleVersion = "2.2.0" glideVersion = "4.9.0" @@ -12,20 +12,16 @@ robolectricVersion = "4.3" openApiGeneratorVersion = "5.1.0" guavaVersion = "30.1-jre" kotlinxSerializationVersion = "1.1.0" -coroutinesVersion = "1.4.2-native-mt" -ktorClientVersion = "1.5.2" +coroutinesVersion = "1.5.0-native-mt" +ktorClientVersion = "1.6.0" detektVersion = "1.15.0" -mokoResourcesVersion = "0.15.1" -mokoMvvmVersion = "0.10.1" -mokoErrorsVersion = "0.3.3" -mokoTestVersion = "0.3.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" -compileSdk = "30" -targetSdk = "30" -minSdk = "16" - [libraries] appCompat = { module = "androidx.appcompat:appcompat", version.ref = "androidAppCompatVersion" } glide = { module = "com.github.bumptech.glide:glide", version.ref = "glideVersion" } diff --git a/network-bignum/build.gradle.kts b/network-bignum/build.gradle.kts index 27e023c..30e237f 100644 --- a/network-bignum/build.gradle.kts +++ b/network-bignum/build.gradle.kts @@ -3,10 +3,9 @@ */ 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("android-publication-convention") } dependencies { 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..5cd65ef --- /dev/null +++ b/network-build-logic/src/main/kotlin/publication-convention.gradle.kts @@ -0,0 +1,65 @@ +/* + * 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 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") + } + } + + 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-errors/build.gradle.kts b/network-errors/build.gradle.kts index 8b89d26..1c1ddb5 100644 --- a/network-errors/build.gradle.kts +++ b/network-errors/build.gradle.kts @@ -3,11 +3,10 @@ */ 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("android-publication-convention") } dependencies { diff --git a/network-generator/build.gradle.kts b/network-generator/build.gradle.kts index 2ebed1c..7f5e205 100644 --- a/network-generator/build.gradle.kts +++ b/network-generator/build.gradle.kts @@ -5,7 +5,7 @@ import java.util.Base64 plugins { - id("org.jetbrains.kotlin.jvm") version("1.5.10") + id("org.jetbrains.kotlin.jvm") version("1.5.20") id("io.gitlab.arturbosch.detekt") version("1.15.0") id("org.gradle.maven-publish") id("signing") @@ -26,7 +26,7 @@ dependencies { implementation(libs.guava) implementation(libs.openApiGenerator) - compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10") + compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20") "detektPlugins"(rootProject.libs.detektFormatting) } diff --git a/network/build.gradle.kts b/network/build.gradle.kts index e0c7863..f8dff9e 100644 --- a/network/build.gradle.kts +++ b/network/build.gradle.kts @@ -3,11 +3,10 @@ */ 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("android-publication-convention") } kotlin { @@ -39,11 +38,6 @@ kotlin { implementation(libs.kotlinTestJUnit) } } - - val iosArm64Main by getting - val iosX64Main by getting - - iosArm64Main.dependsOn(iosX64Main) } } @@ -54,13 +48,13 @@ dependencies { androidMainApi(libs.ktorClientOkHttp) iosMainApi(libs.ktorClientIos) - androidMainImplementation(libs.appCompat) + "androidMainImplementation"(libs.appCompat) commonTestImplementation(libs.ktorClientMock) commonTestImplementation(libs.kotlinTest) commonTestImplementation(libs.kotlinTestAnnotations) - androidTestImplementation(libs.kotlinTestJUnit) + "androidTestImplementation"(libs.kotlinTestJUnit) } tasks.named("publishToMavenLocal") { 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/sample/android-app/build.gradle.kts b/sample/android-app/build.gradle.kts index ed527b4..d05faa6 100644 --- a/sample/android-app/build.gradle.kts +++ b/sample/android-app/build.gradle.kts @@ -3,45 +3,19 @@ */ plugins { - id("com.android.application") - id("kotlin-android") + id("android-app-convention") + id("detekt-convention") id("kotlin-kapt") } android { - compileSdkVersion(libs.versions.compileSdk.get().toInt()) - buildFeatures.dataBinding = true - dexOptions { - javaMaxHeapSize = "2g" - } - defaultConfig { - minSdkVersion(libs.versions.minSdk.get().toInt()) - targetSdkVersion(libs.versions.targetSdk.get().toInt()) - 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") } } diff --git a/sample/mpp-library/build.gradle.kts b/sample/mpp-library/build.gradle.kts index 9f5631b..fd602c6 100644 --- a/sample/mpp-library/build.gradle.kts +++ b/sample/mpp-library/build.gradle.kts @@ -4,14 +4,20 @@ 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(libs.coroutines) @@ -30,7 +36,7 @@ dependencies { commonMainApi(projects.networkBignum) commonMainApi(projects.networkErrors) - androidMainImplementation(libs.lifecycle) + "androidMainImplementation"(libs.lifecycle) commonTestImplementation(libs.ktorClientMock) commonTestImplementation(libs.kotlinTest) diff --git a/settings.gradle.kts b/settings.gradle.kts index 5514ec2..a396467 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,15 +5,6 @@ enableFeaturePreview("VERSION_CATALOGS") enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") -pluginManagement { - repositories { - mavenCentral() - google() - - gradlePluginPortal() - } -} - dependencyResolutionManagement { repositories { mavenCentral() @@ -21,13 +12,12 @@ dependencyResolutionManagement { jcenter { content { - includeGroup("org.jetbrains.trove4j") includeGroup("org.jetbrains.kotlinx") } } } } - +includeBuild("network-build-logic") includeBuild("network-generator") include(":network") From 8efe6b052bb558fb501541127867bb6fddb57b91 Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Tue, 29 Jun 2021 12:42:03 +0700 Subject: [PATCH 15/20] =?UTF-8?q?#138=20use=20=D1=81onvention=20plugin=20i?= =?UTF-8?q?n=20network-generator?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle/libs.versions.toml | 1 + network-generator/build.gradle.kts | 78 ++++----------------------- network-generator/settings.gradle.kts | 2 + 3 files changed, 12 insertions(+), 69 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7c44247..14d15bd 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -51,6 +51,7 @@ kbignum = { module = "com.soywiz.korlibs.kbignum:kbignum", version.ref = "kbign 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/network-generator/build.gradle.kts b/network-generator/build.gradle.kts index 7f5e205..0a46f05 100644 --- a/network-generator/build.gradle.kts +++ b/network-generator/build.gradle.kts @@ -2,13 +2,11 @@ * 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.5.20") - id("io.gitlab.arturbosch.detekt") version("1.15.0") - id("org.gradle.maven-publish") - id("signing") + id("detekt-convention") + id("publication-convention") + } buildscript { @@ -22,13 +20,9 @@ version = libs.versions.mokoNetworkVersion.get() dependencies { implementation(gradleKotlinDsl()) - + compileOnly(libs.kotlinGradlePlugin) implementation(libs.guava) implementation(libs.openApiGenerator) - - compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20") - - "detektPlugins"(rootProject.libs.detektFormatting) } java { @@ -38,64 +32,10 @@ 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") - } - } - } +publishing.publications.register("mavenJava", MavenPublication::class) { + from(components["java"]) +} - 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 1be7afc..7276606 100644 --- a/network-generator/settings.gradle.kts +++ b/network-generator/settings.gradle.kts @@ -31,3 +31,5 @@ dependencyResolutionManagement { } } +includeBuild("../network-build-logic") + From ec556125c1e42ff3b218133ed72d82f10fae449b Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Tue, 29 Jun 2021 12:43:34 +0700 Subject: [PATCH 16/20] #138 test way to force include coroutines native-mt --- build.gradle.kts | 7 ------- network/build.gradle.kts | 8 +++++++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index bcaea83..d6069d9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,8 +2,6 @@ * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. */ -import java.util.Base64 - buildscript { repositories { mavenCentral() @@ -24,11 +22,6 @@ allprojects { group = "dev.icerock.moko" version = libs.versions.mokoNetworkVersion.get() } - configurations.configureEach { - resolutionStrategy { - force("${rootProject.libs.coroutines.get().module}:${rootProject.libs.coroutines.get().versionConstraint}") - } - } } tasks.register("clean", Delete::class).configure { diff --git a/network/build.gradle.kts b/network/build.gradle.kts index f8dff9e..737536a 100644 --- a/network/build.gradle.kts +++ b/network/build.gradle.kts @@ -1,3 +1,5 @@ +import org.gradle.api.internal.artifacts.dependencies.DefaultDependencyConstraint.strictly + /* * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. */ @@ -42,7 +44,11 @@ kotlin { } dependencies { - + commonMainImplementation(libs.coroutines) { + version { + require("1.5.0-native-mt") + } + } commonMainApi(libs.kotlinSerialization) commonMainApi(libs.ktorClient) androidMainApi(libs.ktorClientOkHttp) From bcc2410d6b24dcb66aec669bd290b191883d669e Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Tue, 29 Jun 2021 12:54:38 +0700 Subject: [PATCH 17/20] #138 fixes --- network-generator/build.gradle.kts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/network-generator/build.gradle.kts b/network-generator/build.gradle.kts index 0a46f05..027fea6 100644 --- a/network-generator/build.gradle.kts +++ b/network-generator/build.gradle.kts @@ -32,10 +32,6 @@ java { withSourcesJar() } -publishing.publications.register("mavenJava", MavenPublication::class) { - from(components["java"]) -} - tasks.withType().configureEach { kotlinOptions.jvmTarget = "1.8" } From 79b4cac413a063db9b60147bdbb5f087f646fa85 Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Tue, 29 Jun 2021 13:39:48 +0700 Subject: [PATCH 18/20] #138 change forced coroutines to more readable connection --- build.gradle.kts | 11 +++++++++++ network/build.gradle.kts | 6 +----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index d6069d9..31f0a5e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,7 @@ /* * Copyright 2019 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 { @@ -22,6 +23,16 @@ allprojects { group = "dev.icerock.moko" 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) + } + } } tasks.register("clean", Delete::class).configure { diff --git a/network/build.gradle.kts b/network/build.gradle.kts index 737536a..249473a 100644 --- a/network/build.gradle.kts +++ b/network/build.gradle.kts @@ -44,11 +44,7 @@ kotlin { } dependencies { - commonMainImplementation(libs.coroutines) { - version { - require("1.5.0-native-mt") - } - } + commonMainImplementation(libs.coroutines) commonMainApi(libs.kotlinSerialization) commonMainApi(libs.ktorClient) androidMainApi(libs.ktorClientOkHttp) From 154929ef82771ae1445d00f4d9c144784d3de9e3 Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Tue, 29 Jun 2021 15:11:34 +0700 Subject: [PATCH 19/20] #138 fixes: use multiplatform publication plugin and added lost developers --- gradle/libs.versions.toml | 2 -- network-bignum/build.gradle.kts | 2 +- .../src/main/kotlin/publication-convention.gradle.kts | 11 ++++++++++- network-errors/build.gradle.kts | 2 +- network/build.gradle.kts | 4 +--- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 14d15bd..8b6a65d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,7 +14,6 @@ guavaVersion = "30.1-jre" kotlinxSerializationVersion = "1.1.0" coroutinesVersion = "1.5.0-native-mt" ktorClientVersion = "1.6.0" -detektVersion = "1.15.0" mokoResourcesVersion = "0.16.0" mokoMvvmVersion = "0.11.0" mokoErrorsVersion = "0.4.0" @@ -55,4 +54,3 @@ kotlinGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", ver 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" } -detektFormatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detektVersion" } diff --git a/network-bignum/build.gradle.kts b/network-bignum/build.gradle.kts index 30e237f..38a5efd 100644 --- a/network-bignum/build.gradle.kts +++ b/network-bignum/build.gradle.kts @@ -5,7 +5,7 @@ plugins { id("multiplatform-library-convention") id("dev.icerock.mobile.multiplatform.android-manifest") - id("android-publication-convention") + id("publication-convention") } dependencies { diff --git a/network-build-logic/src/main/kotlin/publication-convention.gradle.kts b/network-build-logic/src/main/kotlin/publication-convention.gradle.kts index 5cd65ef..3d13cf1 100644 --- a/network-build-logic/src/main/kotlin/publication-convention.gradle.kts +++ b/network-build-logic/src/main/kotlin/publication-convention.gradle.kts @@ -5,7 +5,6 @@ import java.util.Base64 plugins { - id("javadoc-stub-convention") id("org.gradle.maven-publish") id("signing") } @@ -40,6 +39,16 @@ publishing { 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 { diff --git a/network-errors/build.gradle.kts b/network-errors/build.gradle.kts index 1c1ddb5..b58abba 100644 --- a/network-errors/build.gradle.kts +++ b/network-errors/build.gradle.kts @@ -6,7 +6,7 @@ plugins { id("multiplatform-library-convention") id("dev.icerock.mobile.multiplatform.android-manifest") id("dev.icerock.mobile.multiplatform-resources") - id("android-publication-convention") + id("publication-convention") } dependencies { diff --git a/network/build.gradle.kts b/network/build.gradle.kts index 249473a..a9ad1af 100644 --- a/network/build.gradle.kts +++ b/network/build.gradle.kts @@ -1,5 +1,3 @@ -import org.gradle.api.internal.artifacts.dependencies.DefaultDependencyConstraint.strictly - /* * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. */ @@ -8,7 +6,7 @@ plugins { id("multiplatform-library-convention") id("dev.icerock.mobile.multiplatform.android-manifest") id("org.jetbrains.kotlin.plugin.serialization") - id("android-publication-convention") + id("publication-convention") } kotlin { From 5495d207b4b090d4ac5f99c8382ea247f19b13e0 Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Tue, 29 Jun 2021 15:53:30 +0700 Subject: [PATCH 20/20] #138 added javadoc-stub-plugin to multiplatform modules --- network-bignum/build.gradle.kts | 1 + network-errors/build.gradle.kts | 1 + network/build.gradle.kts | 1 + 3 files changed, 3 insertions(+) diff --git a/network-bignum/build.gradle.kts b/network-bignum/build.gradle.kts index 38a5efd..a22b8eb 100644 --- a/network-bignum/build.gradle.kts +++ b/network-bignum/build.gradle.kts @@ -6,6 +6,7 @@ plugins { id("multiplatform-library-convention") id("dev.icerock.mobile.multiplatform.android-manifest") id("publication-convention") + id("javadoc-stub-convention") } dependencies { diff --git a/network-errors/build.gradle.kts b/network-errors/build.gradle.kts index b58abba..37319ad 100644 --- a/network-errors/build.gradle.kts +++ b/network-errors/build.gradle.kts @@ -7,6 +7,7 @@ plugins { id("dev.icerock.mobile.multiplatform.android-manifest") id("dev.icerock.mobile.multiplatform-resources") id("publication-convention") + id("javadoc-stub-convention") } dependencies { diff --git a/network/build.gradle.kts b/network/build.gradle.kts index a9ad1af..a9eac80 100644 --- a/network/build.gradle.kts +++ b/network/build.gradle.kts @@ -7,6 +7,7 @@ plugins { id("dev.icerock.mobile.multiplatform.android-manifest") id("org.jetbrains.kotlin.plugin.serialization") id("publication-convention") + id("javadoc-stub-convention") } kotlin {