1+ import com.android.build.gradle.LibraryExtension
12import com.jfrog.bintray.gradle.tasks.BintrayUploadTask
23import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
34import java.net.URI
45
6+ buildscript {
7+ repositories {
8+ google()
9+ }
10+ dependencies {
11+ classpath(" com.android.tools.build:gradle:3.5.2" )
12+ }
13+ }
514
615plugins {
7- id(" kotlin-multiplatform" ) version " 1.3.50 "
8- id(" kotlinx-serialization" ) version " 1.3.50 "
16+ id(" kotlin-multiplatform" ) version " 1.3.60 "
17+ id(" kotlinx-serialization" ) version " 1.3.60 "
918 id(" maven-publish" )
1019 id(" com.jfrog.bintray" ) version " 1.8.4"
1120 id(" com.github.kukuhyoniatmoko.buildconfigkotlin" ) version " 1.0.5"
1221}
1322
14- version = Library .version
15- group = Library .group
23+ apply (plugin = " com.android.library" )
1624
1725repositories {
1826 jcenter()
27+ google()
1928 mavenCentral()
2029 maven { url = URI (" https://dl.bintray.com/kotlin/ktor" ) }
2130 maven { url = URI (" https://kotlin.bintray.com/kotlinx" ) }
2231}
2332
33+ version = Library .version
34+ group = Library .group
35+
36+ extensions.getByType(LibraryExtension ::class .java).apply {
37+ compileSdkVersion(29 )
38+
39+ defaultConfig {
40+ minSdkVersion(17 )
41+ targetSdkVersion(29 )
42+ testInstrumentationRunner = " androidx.test.runner.AndroidJUnitRunner"
43+ }
44+
45+ testOptions.unitTests.isIncludeAndroidResources = true
46+
47+ sourceSets {
48+ getByName(" main" ) {
49+ manifest.srcFile(" src/androidMain/AndroidManifest.xml" )
50+ java.srcDirs(" src/androidMain/kotlin" )
51+ res.srcDirs(" src/androidMain/res" )
52+ }
53+ getByName(" test" ) {
54+ java.srcDirs(" src/androidTest/kotlin" )
55+ res.srcDirs(" src/androidTest/res" )
56+ }
57+ }
58+
59+ compileOptions {
60+ sourceCompatibility = JavaVersion .VERSION_1_8
61+ targetCompatibility = JavaVersion .VERSION_1_8
62+ }
63+ testOptions.unitTests.isIncludeAndroidResources = true
64+ }
65+
2466buildConfigKotlin {
2567 sourceSet(" metadata" ) {
2668 buildConfig(name = " version" , value = Library .version)
@@ -35,6 +77,17 @@ kotlin {
3577 }
3678 }
3779 }
80+ android {
81+ mavenPublication {
82+ artifactId = " ${Library .artifact} -android"
83+ }
84+ publishLibraryVariants(" release" )
85+ compilations.all {
86+ kotlinOptions {
87+ jvmTarget = " 1.8"
88+ }
89+ }
90+ }
3891 sourceSets {
3992 all {
4093 languageSettings.progressiveMode = true
@@ -76,6 +129,26 @@ kotlin {
76129 implementation(Ktor (" client-android" ))
77130 }
78131 }
132+ val androidMain by getting {
133+ dependencies {
134+ api(kotlin(" stdlib-jdk8" ))
135+ api(Ktor (" client-core-jvm" ))
136+ api(Ktor (" client-json-jvm" ))
137+ api(Ktor (" client-logging-jvm" ))
138+ api(Ktor (" client-serialization-jvm" ))
139+ }
140+ }
141+ val androidTest by getting {
142+ dependencies {
143+ implementation(kotlin(" test" ))
144+ implementation(kotlin(" test-junit" ))
145+ implementation(Ktor (" client-mock-jvm" ))
146+ implementation(Ktor (" client-android" ))
147+ implementation(AndroidTestRunner ())
148+ implementation(AndroidTestExtRunner ())
149+ implementation(Robolectric ())
150+ }
151+ }
79152 }
80153}
81154
@@ -151,9 +224,8 @@ bintray {
151224
152225tasks {
153226 val bintrayUpload by getting(BintrayUploadTask ::class ) {
154- dependsOn(publishToMavenLocal)
155227 doFirst {
156- setPublications(" jvm" , " metadata" )
228+ setPublications(" jvm" , " metadata" , " androidRelease " )
157229 }
158230 }
159231 withType<KotlinCompile > {
0 commit comments