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.0" )
12+ }
13+ }
514
615plugins {
716 id(" kotlin-multiplatform" ) version " 1.3.50"
@@ -11,16 +20,48 @@ plugins {
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(28 )
38+
39+ defaultConfig {
40+ minSdkVersion(17 )
41+ targetSdkVersion(28 )
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+ }
64+
2465buildConfigKotlin {
2566 sourceSet(" metadata" ) {
2667 buildConfig(name = " version" , value = Library .version)
@@ -35,6 +76,17 @@ kotlin {
3576 }
3677 }
3778 }
79+ android {
80+ mavenPublication {
81+ artifactId = " ${Library .artifact} -android"
82+ }
83+ publishLibraryVariants(" release" )
84+ compilations.all {
85+ kotlinOptions {
86+ jvmTarget = " 1.8"
87+ }
88+ }
89+ }
3890 sourceSets {
3991 all {
4092 languageSettings.progressiveMode = true
@@ -76,6 +128,26 @@ kotlin {
76128 implementation(Ktor (" client-android" ))
77129 }
78130 }
131+ val androidMain by getting {
132+ dependencies {
133+ api(kotlin(" stdlib-jdk8" ))
134+ api(Ktor (" client-core-jvm" ))
135+ api(Ktor (" client-json-jvm" ))
136+ api(Ktor (" client-logging-jvm" ))
137+ api(Ktor (" client-serialization-jvm" ))
138+ }
139+ }
140+ val androidTest by getting {
141+ dependencies {
142+ implementation(kotlin(" test" ))
143+ implementation(kotlin(" test-junit" ))
144+ implementation(Ktor (" client-mock-jvm" ))
145+ implementation(Ktor (" client-android" ))
146+ implementation(AndroidTestRunner ())
147+ implementation(AndroidTestExtRunner ())
148+ implementation(Robolectric ())
149+ }
150+ }
79151 }
80152}
81153
@@ -151,9 +223,8 @@ bintray {
151223
152224tasks {
153225 val bintrayUpload by getting(BintrayUploadTask ::class ) {
154- dependsOn(publishToMavenLocal)
155226 doFirst {
156- setPublications(" jvm" , " metadata" )
227+ setPublications(" jvm" , " metadata" , " androidRelease " )
157228 }
158229 }
159230 withType<KotlinCompile > {
0 commit comments