-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle.kts
207 lines (181 loc) · 5.5 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
import java.util.*
plugins {
kotlin("multiplatform") version "1.8.20"
kotlin("plugin.serialization") version "1.8.20"
id("com.android.library")
id("org.jlleitschuh.gradle.ktlint") version "11.3.1"
`maven-publish`
id("signing")
}
// expose properties
val sonatypeStaging = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
val sonatypeSnapshots = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
val local = Properties()
val localProperties: File = rootProject.file("local.properties")
if (localProperties.exists()) {
localProperties.inputStream().use { local.load(it) }
}
val sonatypePasswordEnv = System.getenv("sonatypePasswordEnv")
val sonatypeUsernameEnv = System.getenv("sonatypeUsernameEnv")
val projectGithubUrl: String by project
val projectGithubSCM: String by project
val projectGithubSCMSSL: String by project
val projectDescription: String by project
val developerId: String by project
val developerName: String by project
val developerEmail: String by project
val group: String by project
val project_version: String by project
version = project_version
repositories {
google()
mavenCentral()
}
val ktor_version: String by project
val kotlinx_coroutines_version: String by project
val kermit_version: String by project
kotlin {
android {
publishLibraryVariants("release", "debug")
}
jvm {
compilations.all {
kotlinOptions.jvmTarget = "11"
}
}
ios("ios") {
binaries.framework {
baseName = "jsonrpc"
}
}
iosSimulatorArm64 {
binaries.framework {
baseName = "jsonrpc"
}
}
js(IR) {
browser()
}
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.ktor:ktor-client-core:$ktor_version")
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktor_version")
implementation("io.ktor:ktor-client-logging:$ktor_version")
implementation("io.ktor:ktor-client-content-negotiation:$ktor_version")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinx_coroutines_version")
implementation("co.touchlab:kermit:$kermit_version")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val androidMain by getting {
dependencies {
implementation("io.ktor:ktor-client-android:$ktor_version")
}
}
val androidTest by getting {
dependencies {
implementation("junit:junit:4.13.2")
}
}
val jvmMain by getting {
dependencies {
implementation("io.ktor:ktor-client-java:$ktor_version")
}
}
val jvmTest by getting {
dependencies {
implementation("junit:junit:4.13.2")
}
}
val iosMain by getting {
dependencies {
implementation("io.ktor:ktor-client-darwin:$ktor_version")
}
}
val iosTest by getting
val iosSimulatorArm64Main by getting
iosSimulatorArm64Main.dependsOn(iosMain)
val iosSimulatorArm64Test by getting
iosSimulatorArm64Test.dependsOn(iosTest)
val jsMain by getting {
dependencies {
implementation("io.ktor:ktor-client-js:$ktor_version")
}
}
val jsTest by getting
}
}
android {
compileSdk = 31
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdk = 24
targetSdk = 31
}
testOptions {
unitTests.isReturnDefaultValues = true
}
}
fun SigningExtension.whenRequired(block: () -> Boolean) {
setRequired(block)
}
val javadocJar by tasks.creating(Jar::class) {
archiveClassifier.value("javadoc")
}
publishing {
repositories {
maven {
url = uri(sonatypeStaging)
credentials {
username = sonatypeUsernameEnv
password = sonatypePasswordEnv
}
}
}
publications.all {
this as MavenPublication
println(name)
artifact(javadocJar)
pom {
name.set(group)
description.set(projectDescription)
url.set(projectGithubUrl)
licenses {
license {
name.set("MIT License")
url.set("http://opensource.org/licenses/MIT")
}
}
developers {
developer {
id.set(developerId)
name.set(developerName)
email.set(developerEmail)
}
}
scm {
url.set(projectGithubUrl)
connection.set(projectGithubSCM)
developerConnection.set(projectGithubSCMSSL)
}
}
}
}
signing {
whenRequired { gradle.taskGraph.hasTask("publish") }
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications)
}
ktlint {
version.set("0.41.0")
}
rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin> {
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().nodeVersion = "16.0.0"
}