-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.gradle.kts
208 lines (185 loc) · 6.96 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
import org.jetbrains.kotlin.cli.common.toBooleanLenient
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
val isSnapshotUpload = System.getProperty("snapshot").toBooleanLenient() ?: false
val libVersion = "0.2.11"
val gitName = "abc-${project.name}"
buildscript {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
dependencies {
val agpVersion: String by project
val kotlinVersion: String by project
classpath("com.android.tools.build:gradle:$agpVersion")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
}
}
plugins {
id("com.android.library")
id("maven-publish")
id("signing")
kotlin("multiplatform")
kotlin("native.cocoapods")
}
allprojects {
ext {
set("compileSdkVersion", 30)
set("minSdkVersion", 21)
set("targetSdkVersion", 30)
}
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
group = "com.linecorp.abc"
version = if (isSnapshotUpload) "$libVersion-SNAPSHOT" else libVersion
val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
}
afterEvaluate {
extensions.findByType<PublishingExtension>()?.apply {
repositories {
maven {
url = if (isSnapshotUpload) {
uri("https://oss.sonatype.org/content/repositories/snapshots/")
} else {
uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
}
val sonatypeUsername: String? by project
val sonatypePassword: String? by project
println("sonatypeUsername, sonatypePassword -> $sonatypeUsername, ${sonatypePassword?.masked()}")
credentials {
username = sonatypeUsername ?: ""
password = sonatypePassword ?: ""
}
}
}
publications.withType<MavenPublication>().configureEach {
artifact(javadocJar.get())
pom {
name.set(artifactId)
description.set("Location Service Manager for Kotlin Multiplatform Mobile iOS and android")
url.set("https://github.com/line/$gitName")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
name.set("LINE Corporation")
email.set("[email protected]")
url.set("https://engineering.linecorp.com/en/")
}
developer {
id.set("pisces")
name.set("Steve Kim")
email.set("[email protected]")
}
developer {
id.set("hansjin")
name.set("SeungJin Han")
email.set("[email protected]")
}
developer {
id.set("sanghyuk.nam")
name.set("Sanghyuk Nam")
email.set("[email protected]")
}
}
scm {
connection.set("scm:[email protected]:line/$gitName.git")
developerConnection.set("scm:git:ssh://github.com:line/$gitName.git")
url.set("http://github.com/line/$gitName")
}
}
}
}
extensions.findByType<SigningExtension>()?.apply {
val publishing = extensions.findByType<PublishingExtension>() ?: return@apply
val signingKey: String? by project
val signingPassword: String? by project
println("signingKey, signingPassword -> ${signingKey?.slice(0..9)}, ${signingPassword?.masked()}")
isRequired = !isSnapshotUpload
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications)
}
tasks.withType<Sign>().configureEach {
onlyIf { !isSnapshotUpload }
}
}
}
kotlin {
val enableGranularSourceSetsMetadata = project.extra["kotlin.mpp.enableGranularSourceSetsMetadata"]?.toString()?.toBoolean() ?: false
if (enableGranularSourceSetsMetadata) {
val iosTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
::iosArm64
else
::iosX64
iosTarget("ios") { }
} else {
ios()
}
android {
publishAllLibraryVariants()
}
sourceSets {
val commonMain by getting
val androidMain by getting {
dependencies {
implementation("com.google.android.gms:play-services-location:18.0.0")
implementation("androidx.startup:startup-runtime:1.1.0")
}
}
val androidAndroidTestRelease by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation("junit:junit:4.13")
implementation("androidx.test:core:1.0.0")
implementation("androidx.test:runner:1.1.0")
implementation("org.mockito.kotlin:mockito-kotlin:2.2.10")
implementation("org.robolectric:robolectric:4.5.1")
}
}
val androidTest by getting {
dependsOn(androidAndroidTestRelease)
}
val iosMain by getting {
dependencies {
implementation("org.jetbrains.kotlinx:atomicfu:0.16.3")
}
}
val iosTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
}
}
android {
val compileSdkVersion = project.ext.get("compileSdkVersion") as Int
val minSdkVersion = project.ext.get("minSdkVersion") as Int
val targetSdkVersion = project.ext.get("targetSdkVersion") as Int
compileSdk = compileSdkVersion
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdk = minSdkVersion
targetSdk = targetSdkVersion
}
buildTypes {
getByName("debug") {
isMinifyEnabled = false
}
}
testOptions {
unitTests.isIncludeAndroidResources = true
unitTests.isReturnDefaultValues = true
}
}
fun String.masked() = map { "*" }.joinToString("")