forked from GitLiveApp/firebase-kotlin-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
281 lines (236 loc) · 10.3 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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
import de.undercouch.gradle.tasks.download.Download
import org.apache.tools.ant.taskdefs.condition.Os
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
plugins {
kotlin("multiplatform") version "1.3.71" apply false
id("de.undercouch.download").version("3.4.3")
id("base")
}
buildscript {
repositories {
jcenter()
google()
gradlePluginPortal()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("com.android.tools.build:gradle:4.0.1")
classpath("de.undercouch:gradle-download-task:4.0.4")
classpath("com.adarshr:gradle-test-logger-plugin:2.0.0")
}
}
val targetSdkVersion by extra(28)
val minSdkVersion by extra(16)
tasks {
val updateVersions by registering {
dependsOn(
"firebase-app:updateVersion", "firebase-app:updateDependencyVersion",
"firebase-auth:updateVersion", "firebase-auth:updateDependencyVersion",
"firebase-common:updateVersion", "firebase-common:updateDependencyVersion",
"firebase-database:updateVersion", "firebase-database:updateDependencyVersion",
"firebase-firestore:updateVersion", "firebase-firestore:updateDependencyVersion",
"firebase-functions:updateVersion", "firebase-functions:updateDependencyVersion"
)
}
}
subprojects {
group = "dev.gitlive"
apply(plugin="com.adarshr.test-logger")
repositories {
mavenLocal()
mavenCentral()
google()
jcenter()
}
tasks.withType<Sign>().configureEach {
onlyIf { !project.gradle.startParameter.taskNames.contains("publishToMavenLocal")
}
}
tasks {
val updateVersion by registering(Exec::class) {
commandLine("npm", "--allow-same-version", "--prefix", projectDir, "version", "${project.property("${project.name}.version")}")
}
val updateDependencyVersion by registering(Copy::class) {
mustRunAfter("updateVersion")
val from = file("package.json")
from.writeText(
from.readText()
.replace("firebase-common\": \"([^\"]+)".toRegex(), "firebase-common\": \"${project.property("firebase-common.version")}")
.replace("firebase-app\": \"([^\"]+)".toRegex(), "firebase-app\": \"${project.property("firebase-app.version")}")
)
}
val copyReadMe by registering(Copy::class) {
from(rootProject.file("README.md"))
into(file("$buildDir/node_module"))
}
val copyPackageJson by registering(Copy::class) {
from(file("package.json"))
into(file("$buildDir/node_module"))
}
val unzipJar by registering(Copy::class) {
val zipFile = File("$buildDir/libs", "${project.name}-js-${project.version}.jar")
from(this.project.zipTree(zipFile))
into("$buildDir/classes/kotlin/js/main/")
}
val copyJS by registering {
mustRunAfter("unzipJar", "copyPackageJson")
doLast {
val from = File("$buildDir/classes/kotlin/js/main/${rootProject.name}-${project.name}.js")
val into = File("$buildDir/node_module/${project.name}.js")
into.createNewFile()
into.writeText(
from.readText()
.replace("require('firebase-kotlin-sdk-", "require('@gitlive/")
// .replace("require('kotlinx-serialization-kotlinx-serialization-runtime')", "require('@gitlive/kotlinx-serialization-runtime')")
)
}
}
val copySourceMap by registering(Copy::class) {
from(file("$buildDir/classes/kotlin/js/main/${project.name}.js.map"))
into(file("$buildDir/node_module"))
}
val prepareForNpmPublish by registering {
dependsOn(
unzipJar,
copyPackageJson,
copySourceMap,
copyReadMe,
copyJS
)
}
val publishToNpm by creating(Exec::class) {
workingDir("$buildDir/node_module")
isIgnoreExitValue = true
if(Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine("cmd", "/c", "npm publish")
} else {
commandLine("npm", "publish")
}
}
withType<Test> {
testLogging {
showExceptions = true
exceptionFormat = TestExceptionFormat.FULL
showStandardStreams = true
showCauses = true
showStackTraces = true
events = setOf(
TestLogEvent.STARTED,
TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_OUT,
TestLogEvent.STANDARD_ERROR
)
}
}
listOf("bootstrap", "update").forEach {
task<Exec>("carthage${it.capitalize()}") {
group = "carthage"
executable = "carthage"
args(
it,
"--project-directory", "src/iosMain/c_interop",
"--platform", "iOS",
"--cache-builds"
)
}
}
if (Os.isFamily(Os.FAMILY_MAC)) {
withType(org.jetbrains.kotlin.gradle.tasks.CInteropProcess::class) {
dependsOn("carthageBootstrap")
}
}
create("carthageClean", Delete::class.java) {
group = "carthage"
delete(File("$projectDir/src/iosMain/c_interop/Carthage"))
delete(File("$projectDir/src/iosMain/c_interop/Cartfile.resolved"))
}
}
// tasks.withType<KotlinCompile<*>> {
// kotlinOptions.freeCompilerArgs += listOf(
// "-Xuse-experimental=kotlin.Experimental",
// "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
// "-Xuse-experimental=kotlinx.serialization.ImplicitReflectionSerializer"
// )
// }
afterEvaluate {
// create the projects node_modules if they don't exist
if(!File("$buildDir/node_module").exists()) {
mkdir("$buildDir/node_module")
}
tasks.named<Delete>("clean") {
dependsOn("carthageClean")
}
dependencies {
"commonMainImplementation"(kotlin("stdlib-common"))
"commonMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.8")
"jsMainImplementation"(kotlin("stdlib-js"))
"jsMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.3.8")
"androidMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.8")
"androidMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.3.6")
"iosMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.8")
"iosMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.8")
"commonTestImplementation"(kotlin("test-common"))
"commonTestImplementation"(kotlin("test-annotations-common"))
"commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.8")
"commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.8")
"jsTestImplementation"(kotlin("test-js"))
"androidAndroidTestImplementation"(kotlin("test-junit"))
"androidAndroidTestImplementation"("junit:junit:4.13")
"androidAndroidTestImplementation"("androidx.test:core:1.2.0")
"androidAndroidTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.8")
"androidAndroidTestImplementation"("androidx.test.ext:junit:1.1.1")
"androidAndroidTestImplementation"("androidx.test:runner:1.2.0")
}
}
apply(plugin="maven-publish")
apply(plugin="signing")
configure<PublishingExtension> {
repositories {
maven {
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2")
credentials {
username = project.findProperty("sonatypeUsername") as String? ?: System.getenv("sonatypeUsername")
password = project.findProperty("sonatypePassword") as String? ?: System.getenv("sonatypePassword")
}
}
}
publications.all {
this as MavenPublication
pom {
name.set("firebase-kotlin-sdk")
description.set("The Firebase Kotlin SDK is a Kotlin-first SDK for Firebase. It's API is similar to the Firebase Android SDK Kotlin Extensions but also supports multiplatform projects, enabling you to use Firebase directly from your common source targeting iOS, Android or JS.")
url.set("https://github.com/GitLiveApp/firebase-kotlin-sdk")
inceptionYear.set("2019")
scm {
url.set("https://github.com/GitLiveApp/firebase-kotlin-sdk")
connection.set("scm:git:https://github.com/GitLiveApp/firebase-kotlin-sdk.git")
developerConnection.set("scm:git:https://github.com/GitLiveApp/firebase-kotlin-sdk.git")
tag.set("HEAD")
}
issueManagement {
system.set("GitHub Issues")
url.set("https://github.com/GitLiveApp/firebase-kotlin-sdk/issues")
}
developers {
developer {
name.set("Nicholas Bransby-Williams")
email.set("[email protected]")
}
}
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
comments.set("A business-friendly OSS license")
}
}
}
}
}
}