Created
November 16, 2019 20:57
-
-
Save Judrummer/bee935282587d2465a4acb17fec26179 to your computer and use it in GitHub Desktop.
Kotlin Multiplatform template gradle file
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
repositories { | |
google() | |
jcenter() | |
mavenCentral() | |
maven { url "https://jitpack.io" } | |
} | |
import org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask | |
apply plugin: 'com.android.library' | |
apply plugin: 'kotlin-multiplatform' | |
apply plugin: 'kotlinx-serialization' | |
apply plugin: 'kotlin-kapt' | |
android { | |
compileSdkVersion 29 | |
defaultConfig { | |
minSdkVersion 21 | |
targetSdkVersion 29 | |
versionCode 1 | |
versionName '1.0' | |
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner' | |
} | |
buildTypes { | |
release { | |
minifyEnabled false | |
} | |
} | |
packagingOptions { | |
exclude("META-INF/ktor-http.kotlin_module") | |
exclude("META-INF/kotlinx-io.kotlin_module") | |
exclude("META-INF/atomicfu.kotlin_module") | |
exclude("META-INF/ktor-utils.kotlin_module") | |
exclude("META-INF/kotlinx-coroutines-io.kotlin_module") | |
exclude("META-INF/ktor-client-json.kotlin_module") | |
exclude("META-INF/ktor-client-logging.kotlin_module") | |
exclude("META-INF/ktor-client-core.kotlin_module") | |
exclude("META-INF/kotlinx-coroutines-core.kotlin_module") | |
exclude("META-INF/ktor-client-serialization.kotlin_module") | |
exclude("META-INF/ktor-http-cio.kotlin_module") | |
exclude("META-INF/kotlinx-serialization-runtime.kotlin_module") | |
} | |
} | |
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { | |
sourceCompatibility = JavaVersion.VERSION_1_8 | |
targetCompatibility = JavaVersion.VERSION_1_8 | |
kotlinOptions { | |
jvmTarget = '1.8' | |
} | |
} | |
dependencies { | |
implementation fileTree(dir: 'libs', include: ['*.jar']) | |
} | |
kotlin { | |
android("android") | |
// This is for iPhone emulator | |
// Switch here to iosArm64 (or iosArm32) to build library for iPhone device | |
iosX64("ios") { | |
binaries { | |
framework { | |
freeCompilerArgs.add("-Xobjc-generics") // to enable generic | |
} | |
} | |
} | |
task fatFrameworkDebug(type: FatFrameworkTask) { | |
baseName = "core" | |
destinationDir = file("${rootProject.rootDir}/iosApp") //Change this to be your ios project directory | |
from(targets.ios.binaries.getFramework("DEBUG")) | |
} | |
task fatFrameworkRelease(type: FatFrameworkTask) { | |
baseName = "core" | |
destinationDir = file("${rootProject.rootDir}/iosApp") //Change this to be your ios project directory | |
from(targets.ios.binaries.getFramework("RELEASE")) | |
} | |
sourceSets { | |
def ktorVersion = "1.2.5" | |
def kotlinVersion = "1.3.50" | |
def kotlinCoroutineVersion = "1.3.2" | |
commonMain { | |
dependencies { | |
implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion" | |
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.13.0" | |
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$kotlinCoroutineVersion" | |
implementation "io.ktor:ktor-client-core:$ktorVersion" | |
implementation "io.ktor:ktor-client-json:$ktorVersion" | |
implementation "io.ktor:ktor-client-serialization:$ktorVersion" | |
implementation "io.ktor:ktor-client-logging:$ktorVersion" | |
implementation "com.russhwolf:multiplatform-settings:0.4" | |
} | |
} | |
androidMain { | |
dependencies { | |
implementation 'androidx.appcompat:appcompat:1.1.0' | |
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" | |
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion" | |
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinCoroutineVersion" | |
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutineVersion" | |
implementation "io.ktor:ktor-client-android:$ktorVersion" | |
implementation "io.ktor:ktor-client-core-jvm:$ktorVersion" | |
implementation "io.ktor:ktor-client-json-jvm:$ktorVersion" | |
implementation "io.ktor:ktor-client-okhttp:$ktorVersion" | |
implementation "io.ktor:ktor-client-logging-jvm:$ktorVersion" | |
implementation "io.ktor:ktor-client-serialization-jvm:$ktorVersion" | |
implementation "com.squareup.okhttp3:okhttp:4.0.1" | |
implementation "ch.qos.logback:logback-classic:1.2.3" | |
} | |
} | |
androidTest { | |
dependencies { | |
implementation "org.jetbrains.kotlin:kotlin-test" | |
implementation "org.jetbrains.kotlin:kotlin-test-junit" | |
implementation "io.mockk:mockk:1.9.3" | |
} | |
} | |
iosMain { | |
dependencies { | |
implementation "io.ktor:ktor-client-ios:$ktorVersion" | |
implementation "io.ktor:ktor-client-core-native:$ktorVersion" | |
implementation "io.ktor:ktor-client-json-native:$ktorVersion" | |
implementation "io.ktor:ktor-client-logging-native:$ktorVersion" | |
implementation "io.ktor:ktor-client-serialization-native:$ktorVersion" | |
} | |
} | |
} | |
} | |
configurations { | |
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
// Top-level build file where you can add configuration options common to all sub-projects/modules. | |
buildscript { | |
repositories { | |
google() | |
jcenter() | |
} | |
dependencies { | |
classpath 'com.android.tools.build:gradle:3.5.2' | |
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50" | |
classpath "org.jetbrains.kotlin:kotlin-serialization:1.3.50" | |
} | |
} | |
allprojects { | |
repositories { | |
google() | |
jcenter() | |
} | |
} | |
task clean(type: Delete) { | |
delete rootProject.buildDir | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment