-
-
Save Ribesg/d76208f8d921cb22b50347e87014c144 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetPreset | |
repositories { | |
google().apply { | |
content { | |
excludeGroup("Kotlin/Native") | |
} | |
} | |
jcenter { | |
content { | |
excludeGroup("Kotlin/Native") | |
} | |
} | |
mavenCentral().apply { | |
content { | |
excludeGroup("Kotlin/Native") | |
} | |
} | |
maven("https://dl.bintray.com/kotlin/kotlinx") { | |
content { | |
excludeGroup("Kotlin/Native") | |
} | |
} | |
maven("https://dl.bintray.com/kotlin/ktor") { | |
content { | |
excludeGroup("Kotlin/Native") | |
} | |
} | |
} | |
plugins { | |
id("com.android.application") version "3.3.0" | |
kotlin("multiplatform") version "1.3.20" | |
id("kotlinx-serialization") version "1.3.20" | |
} | |
android { | |
compileSdkVersion(28) | |
defaultConfig { | |
minSdkVersion(19) | |
targetSdkVersion(28) | |
} | |
sourceSets { | |
val main by getting { | |
setRoot("src/androidMain") | |
} | |
val test by getting { | |
setRoot("src/androidTest") | |
} | |
} | |
packagingOptions { | |
pickFirst("META-INF/ktor-http.kotlin_module") | |
pickFirst("META-INF/kotlinx-io.kotlin_module") | |
pickFirst("META-INF/atomicfu.kotlin_module") | |
pickFirst("META-INF/ktor-utils.kotlin_module") | |
pickFirst("META-INF/kotlinx-coroutines-io.kotlin_module") | |
pickFirst("META-INF/ktor-client-json.kotlin_module") | |
pickFirst("META-INF/ktor-client-core.kotlin_module") | |
} | |
} | |
kotlin { | |
android() | |
val iosTargetName = if (project.hasProperty("device")) "iosArm64" else "iosX64" | |
val iosTargetPreset = presets.getByName<KotlinNativeTargetPreset>(iosTargetName) | |
targetFromPreset(iosTargetPreset, "ios") { | |
binaries { | |
framework() | |
} | |
} | |
sourceSets { | |
val commonMain by getting { | |
dependencies { | |
implementation(kotlin("stdlib-common")) | |
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:0.10.0") | |
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.1.1") | |
implementation("io.ktor:ktor-client-core:1.1.2") | |
implementation("io.ktor:ktor-client-json:1.1.2") | |
} | |
} | |
val androidMain by getting { | |
dependencies { | |
implementation(kotlin("stdlib")) | |
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.10.0") | |
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1") | |
implementation("io.ktor:ktor-client-android:1.1.2") | |
implementation("io.ktor:ktor-client-json-jvm:1.1.2") | |
} | |
} | |
val iosMain by getting { | |
dependencies { | |
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:0.10.0") | |
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.1.1") | |
implementation("io.ktor:ktor-client-ios:1.1.2") | |
implementation("io.ktor:ktor-client-json-native:1.1.2") | |
} | |
} | |
} | |
} | |
// workaround for https://youtrack.jetbrains.com/issue/KT-27170 | |
configurations { | |
create("compileClasspath") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15:54:59: Executing task 'compileKotlinIos'... | |
Executing tasks: [compileKotlinIos] | |
Configuration on demand is an incubating feature. | |
> Configure project : | |
Kotlin Multiplatform Projects are an experimental feature. | |
> Task :compileKotlinIos | |
src/commonMain/kotlin/com/example/mmpp/TimeRepository.kt:3:8: error: unresolved reference: io | |
import io.ktor.client.HttpClient | |
^ | |
src/commonMain/kotlin/com/example/mmpp/TimeRepository.kt:4:8: error: unresolved reference: io | |
import io.ktor.client.features.json.JsonFeature | |
^ | |
src/commonMain/kotlin/com/example/mmpp/TimeRepository.kt:5:8: error: unresolved reference: io | |
import io.ktor.client.request.get | |
^ | |
src/commonMain/kotlin/com/example/mmpp/TimeRepository.kt:6:16: error: unresolved reference: serialization | |
import kotlinx.serialization.Serializable | |
^ | |
src/commonMain/kotlin/com/example/mmpp/TimeRepository.kt:10:26: error: unresolved reference: HttpClient | |
private val client = HttpClient { | |
^ | |
src/commonMain/kotlin/com/example/mmpp/TimeRepository.kt:11:9: error: unresolved reference: install | |
install(JsonFeature) | |
^ | |
src/commonMain/kotlin/com/example/mmpp/TimeRepository.kt:11:17: error: unresolved reference: JsonFeature | |
install(JsonFeature) | |
^ | |
src/commonMain/kotlin/com/example/mmpp/TimeRepository.kt:18:6: error: cannot access 'Serializable': it is internal in 'kotlin.io' | |
@Serializable | |
^ | |
src/commonMain/kotlin/com/example/mmpp/TimeRepository.kt:18:6: error: this class does not have a constructor | |
@Serializable | |
^ | |
> Task :compileKotlinIos FAILED | |
FAILURE: Build failed with an exception. | |
* What went wrong: | |
Execution failed for task ':compileKotlinIos'. | |
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1 | |
* Try: | |
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. | |
* Get more help at https://help.gradle.org | |
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. | |
Use '--warning-mode all' to show the individual deprecation warnings. | |
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings | |
BUILD FAILED in 7s | |
1 actionable task: 1 executed | |
15:55:06: Task execution finished 'compileKotlinIos'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rootProject.name = "MMPP" | |
pluginManagement { | |
repositories { | |
google() | |
gradlePluginPortal() | |
maven("https://kotlin.bintray.com/kotlinx") | |
} | |
resolutionStrategy { | |
eachPlugin { | |
if (requested.id.id == "com.android.application") { | |
useModule("com.android.tools.build:gradle:${requested.version}") | |
} | |
if (requested.id.id == "kotlinx-serialization") { | |
useModule("org.jetbrains.kotlin:kotlin-serialization:${requested.version}") | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment