Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/compilation-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ on:

jobs:
build:
runs-on: macOS-11
runs-on: macOS-latest

steps:
- uses: actions/checkout@v1
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Check plugin
run: ./gradlew -p network-generator build publishToMavenLocal
- name: Check runtime
Expand Down
19 changes: 13 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
publish:
name: Publish library at mavenCentral
runs-on: macOS-11
runs-on: macOS-latest
env:
OSSRH_USER: ${{ secrets.OSSRH_USER }}
OSSRH_KEY: ${{ secrets.OSSRH_KEY }}
Expand All @@ -21,14 +21,21 @@ jobs:

steps:
- uses: actions/checkout@v1
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
- name: Publish plugin
run: ./gradlew -p network-generator publishPlugins -Pgradle.publish.key=${{ secrets.GRADLE_PLUGIN_PORTAL_KEY }} -Pgradle.publish.secret=${{ secrets.GRADLE_PLUGIN_PORTAL_SECRET }}
java-version: 17
- name: Prebuild plugin
run: ./gradlew -p network-generator publishToMavenLocal
- name: Prebuild library
run: ./gradlew publishToMavenLocal
- name: Publish library
run: ./gradlew publish
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
- name: Publish plugin to maven central
run: ./gradlew -p network-generator publishToSonatype closeAndReleaseSonatypeStagingRepository
- name: Publish plugin to Gradle Plugin Portal
run: ./gradlew -p network-generator publishPlugins -Pgradle.publish.key=${{ secrets.GRADLE_PLUGIN_PORTAL_KEY }} -Pgradle.publish.secret=${{ secrets.GRADLE_PLUGIN_PORTAL_SECRET }}

release:
name: Create release
needs: publish
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.classpath
.vscode
.idea
.kotlin
build
*.iml
Pods
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ buildscript {
}

dependencies {
classpath "dev.icerock.moko:network-generator:0.21.2"
classpath "dev.icerock.moko:network-generator:0.22.0"
}
}

Expand All @@ -53,10 +53,10 @@ project build.gradle
apply plugin: "dev.icerock.mobile.multiplatform-network-generator"

dependencies {
commonMainApi("dev.icerock.moko:network:0.21.2")
commonMainApi("dev.icerock.moko:network-engine:0.21.2") // configured HttpClientEngine
commonMainApi("dev.icerock.moko:network-bignum:0.21.2") // kbignum serializer
commonMainApi("dev.icerock.moko:network-errors:0.21.2") // moko-errors integration
commonMainApi("dev.icerock.moko:network:0.22.0")
commonMainApi("dev.icerock.moko:network-engine:0.22.0") // configured HttpClientEngine
commonMainApi("dev.icerock.moko:network-bignum:0.22.0") // kbignum serializer
commonMainApi("dev.icerock.moko:network-errors:0.22.0") // moko-errors integration
}
```

Expand Down
12 changes: 0 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* 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 {
Expand All @@ -25,17 +24,6 @@ val mokoVersion = libs.versions.mokoNetworkVersion.get()
allprojects {
this.group = "dev.icerock.moko"
this.version = mokoVersion

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 {
Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ kotlin.code.style=official

kotlin.mpp.stability.nowarn=true
kotlin.mpp.androidSourceSetLayoutVersion=2
kotlin.mpp.applyDefaultHierarchyTemplate=false

android.useAndroidX=true

mobile.multiplatform.iosTargetWarning=false

xcodeproj=./sample/ios-app

moko.android.targetSdk=33
moko.android.compileSdk=33
moko.android.targetSdk=34
moko.android.compileSdk=34
moko.android.minSdk=16

moko.publish.name=MOKO network
Expand Down
46 changes: 25 additions & 21 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
kotlinVersion = "1.8.10"
kotlinVersion = "2.0.20"

# android
lifecycleViewModelVersion = "2.6.1"
Expand All @@ -12,15 +12,15 @@ openApiGeneratorVersion = "5.2.0"
guavaVersion = "30.1-jre"

# kotlinx
kotlinxSerializationVersion = "1.5.0"
coroutinesVersion = "1.6.4"
kotlinxSerializationVersion = "1.7.3"
coroutinesVersion = "1.9.0"

# moko
mokoResourcesVersion = "0.21.2"
mokoResourcesVersion = "0.24.4"
mokoMvvmVersion = "0.16.0"
mokoErrorsVersion = "0.7.0"
mokoTestVersion = "0.6.1"
mokoNetworkVersion = "0.21.2"
mokoNetworkVersion = "0.22.0"

# tests
espressoCoreVersion = "3.5.1"
Expand All @@ -30,15 +30,15 @@ androidxTestVersion = "1.5.0"
robolectricVersion = "4.9"

# other
ktorClientVersion = "2.2.2"
ktorVersion = "3.0.0"
kbignumVersion = "2.4.12"
multidexVersion = "2.0.1"

[libraries]
# android
appCompat = { module = "androidx.appcompat:appcompat", version.ref = "androidAppCompatVersion" }
glide = { module = "com.github.bumptech.glide:glide", version.ref = "glideVersion" }
lifecycleViewModel = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycleViewModelVersion" }
lifecycleViewModel = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycleViewModelVersion" }
multidex = { module = "androidx.multidex:multidex", version.ref = "multidexVersion" }
coreKtx = { module = "androidx.core:core-ktx", version.ref = "coreKtxVersion" }

Expand All @@ -47,22 +47,26 @@ kotlinSerialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-js
coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutinesVersion" }

# ktor
ktorClientOkHttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktorClientVersion" }
ktorClient = { module = "io.ktor:ktor-client-core", version.ref = "ktorClientVersion" }
ktorClientLogging = { module = "io.ktor:ktor-client-logging", version.ref = "ktorClientVersion" }
ktorClientWebSocket = { module = "io.ktor:ktor-client-websockets", version.ref = "ktorClientVersion" }
ktorClientMock = { module = "io.ktor:ktor-client-mock", version.ref = "ktorClientVersion" }
ktorClientIos = { module = "io.ktor:ktor-client-ios", version.ref = "ktorClientVersion" }
ktorClientOkHttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktorVersion" }
ktorClient = { module = "io.ktor:ktor-client-core", version.ref = "ktorVersion" }
ktorClientLogging = { module = "io.ktor:ktor-client-logging", version.ref = "ktorVersion" }
ktorClientWebSocket = { module = "io.ktor:ktor-client-websockets", version.ref = "ktorVersion" }
ktorClientMock = { module = "io.ktor:ktor-client-mock", version.ref = "ktorVersion" }
ktorClientIos = { module = "io.ktor:ktor-client-ios", version.ref = "ktorVersion" }

ktorServerNetty = { module = "io.ktor:ktor-server-netty", version.ref = "ktorVersion" }
ktorServerCore = { module = "io.ktor:ktor-server-core", version.ref = "ktorVersion" }
ktorServerWebSockets = { module = "io.ktor:ktor-server-websockets", version.ref = "ktorVersion" }

# korlibs
kbignum = { module = "com.soywiz.korlibs.kbignum:kbignum", version.ref = "kbignumVersion" }
kbignum = { module = "com.soywiz.korlibs.kbignum:kbignum", version.ref = "kbignumVersion" }

# moko
mokoMvvmDataBinding = { module = "dev.icerock.moko:mvvm-databinding", version.ref = "mokoMvvmVersion" }
mokoMvvmDataBinding = { module = "dev.icerock.moko:mvvm-databinding", version.ref = "mokoMvvmVersion" }
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" }
mokoErrors = { module = "dev.icerock.moko:errors", version.ref = "mokoErrorsVersion" }

# tests
espressoCore = { module = "androidx.test.espresso:espresso-core", version.ref = "espressoCoreVersion" }
Expand All @@ -72,17 +76,17 @@ robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectr
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" }
kotlinTest = { module = "org.jetbrains.kotlin:kotlin-test-junit", 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" }
kotlinTest = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlinVersion" }
mokoTest = { module = "dev.icerock.moko:test-core", version.ref = "mokoTestVersion" }

# jvm
openApiGenerator = { module = "org.openapitools:openapi-generator-gradle-plugin", version.ref = "openApiGeneratorVersion" }
guava = { module = "com.google.guava:guava", version.ref = "guavaVersion" }
logback = { module = "ch.qos.logback:logback-classic", version = "1.5.21" }

# gradle plugins
kotlinGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlinVersion" }
kotlinSerializationGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlinVersion" }
androidGradlePlugin = { module = "com.android.tools.build:gradle", version = "7.4.2" }
androidGradlePlugin = { module = "com.android.tools.build:gradle", version = "8.5.2" }
mokoResourcesGradlePlugin = { module = "dev.icerock.moko:resources-generator", version.ref = "mokoResourcesVersion" }
mokoGradlePlugin = { module = "dev.icerock.moko:moko-gradle-plugin", version = "0.3.0" }
mokoGradlePlugin = { module = "dev.icerock.moko:moko-gradle-plugin", version = "0.6.0" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
package dev.icerock.moko.network.bignum

import com.soywiz.kbignum.BigNum
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializer
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder

@OptIn(ExperimentalSerializationApi::class)
@Serializer(forClass = BigNum::class)
object BigNumSerializer : KSerializer<BigNum> {
override val descriptor = PrimitiveSerialDescriptor(
Expand Down
7 changes: 6 additions & 1 deletion network-errors/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ dependencies {
commonMainApi(libs.mokoResources)

commonMainImplementation(projects.network)

// temporary workaround for
// e: KLIB resolver: Could not find "dev.icerock.moko:parcelize
// caused moko-errors
iosMainApi("dev.icerock.moko:parcelize:0.9.0")
}

multiplatformResources {
multiplatformResourcesPackage = "dev.icerock.moko.network.errors"
resourcesPackage = "dev.icerock.moko.network.errors"
}
40 changes: 13 additions & 27 deletions network-generator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
* Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("com.gradle.plugin-publish") version ("0.15.0")
id("com.gradle.plugin-publish") version ("1.3.1")
id("java-gradle-plugin")
}

Expand Down Expand Up @@ -42,40 +45,23 @@ java {
withSourcesJar()
}

configure<PublishingExtension> {
publications.register("mavenJava", MavenPublication::class) {
from(components["java"])
tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
}
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = "1.8"
}

gradlePlugin {
website.set("https://github.com/icerockdev/moko-network")
vcsUrl.set("https://github.com/icerockdev/moko-network")

plugins {
create("multiplatform-network-generator") {
id = "dev.icerock.mobile.multiplatform-network-generator"
displayName = "MOKO network generator plugin"
implementationClass = "dev.icerock.moko.network.MultiPlatformNetworkGeneratorPlugin"
description = "Plugin to provide network components for iOS & Android"
tags = listOf("moko-network", "moko", "kotlin", "kotlin-multiplatform")
}
}
}

pluginBundle {
website = "https://github.com/icerockdev/moko-network"
vcsUrl = "https://github.com/icerockdev/moko-network"
description = "Plugin to provide network components for iOS & Android"
tags = listOf("moko-network", "moko", "kotlin", "kotlin-multiplatform")

plugins {
getByName("multiplatform-network-generator") {
displayName = "MOKO network generator plugin"
}
}

mavenCoordinates {
groupId = project.group as String
artifactId = project.name
version = project.version as String
}
}
1 change: 0 additions & 1 deletion network-generator/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/
enableFeaturePreview("VERSION_CATALOGS")

pluginManagement {
repositories {
Expand Down
1 change: 0 additions & 1 deletion network/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ dependencies {

commonTestImplementation(libs.ktorClientMock)
commonTestImplementation(libs.kotlinTest)
commonTestImplementation(libs.kotlinTestAnnotations)

androidTestImplementation(libs.kotlinTestJUnit)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import androidx.core.os.ConfigurationCompat
import dev.icerock.moko.network.plugins.LanguagePlugin

actual class LanguageProvider : LanguagePlugin.LanguageCodeProvider {
override fun getLanguageCode(): String? {
actual override fun getLanguageCode(): String? {
return ConfigurationCompat.getLocales(Resources.getSystem().configuration).get(0)?.language
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

package dev.icerock.moko.network

import dev.icerock.moko.network.plugins.LanguagePlugin
import dev.icerock.moko.network.plugins.LanguagePlugin.LanguageCodeProvider

@Suppress("EmptyDefaultConstructor")
expect class LanguageProvider() : LanguagePlugin.LanguageCodeProvider
expect class LanguageProvider() : LanguageCodeProvider {
override fun getLanguageCode(): String?
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import io.ktor.client.plugins.plugin
import io.ktor.client.statement.bodyAsChannel
import io.ktor.http.isSuccess
import io.ktor.util.AttributeKey
import io.ktor.utils.io.charsets.Charset
import io.ktor.utils.io.charsets.Charsets
import io.ktor.utils.io.core.readText
import io.ktor.utils.io.readRemaining

class ExceptionPlugin(private val exceptionFactory: ExceptionFactory) {

Expand All @@ -36,7 +37,7 @@ class ExceptionPlugin(private val exceptionFactory: ExceptionFactory) {
val call = execute(request)
if (!call.response.status.isSuccess()) {
val packet = call.response.bodyAsChannel().readRemaining()
val responseString = packet.readText(charset = Charset.forName("UTF-8"))
val responseString = packet.readText(charset = Charsets.UTF_8)
throw plugin.exceptionFactory.createException(
request = call.request,
response = call.response,
Expand Down
Loading