1+ import de.undercouch.gradle.tasks.download.Download
2+
13plugins {
24 kotlin(" multiplatform" ) version " 1.3.70" apply false
5+ id(" de.undercouch.download" ).version(" 3.4.3" )
6+ id(" base" )
37}
48
59buildscript {
610 repositories {
11+ jcenter()
712 google()
813 gradlePluginPortal()
914 }
1015 dependencies {
1116 classpath(" com.android.tools.build:gradle:3.4.2" )
17+ classpath(" de.undercouch:gradle-download-task:4.0.4" )
1218 }
1319}
1420
1521val targetSdkVersion by extra(28 )
1622val minSdkVersion by extra(14 )
1723
24+
25+
26+ tasks {
27+ val downloadIOSFirebaseZipFile by creating(Download ::class ) {
28+ onlyIfModified(true )
29+ src(" https://github.com/firebase/firebase-ios-sdk/releases/download/6.17.0/Firebase-6.17.0.zip" )
30+ dest(File (" $buildDir " , " Firebase-6.17.0.zip" ))
31+ overwrite(true )
32+
33+ }
34+
35+ val unzipIOSFirebase by creating(Copy ::class ) {
36+ dependsOn(downloadIOSFirebaseZipFile)
37+ from(zipTree(downloadIOSFirebaseZipFile.dest))
38+ into(" $buildDir " )
39+ outputs.upToDateWhen { File (" $rootDir /$buildDir /Firebase" ).isDirectory }
40+ }
41+
42+ }
43+
1844subprojects {
1945
20- group = " dev.teamhub.firebase"
46+
47+ group = " dev.gitlive"
2148
2249 repositories {
2350 mavenLocal()
@@ -26,6 +53,52 @@ subprojects {
2653 jcenter()
2754 }
2855
56+
57+ tasks {
58+
59+ val copyReadMe by registering(Copy ::class ) {
60+ from(rootProject.file(" README.md" ))
61+ into(file(" $buildDir /node_module" ))
62+ }
63+
64+ val copyPackageJson by registering(Copy ::class ) {
65+ from(file(" package.json" ))
66+ into(file(" $buildDir /node_module" ))
67+ }
68+
69+ val copyJS by registering {
70+ doLast {
71+ val from = File (" $buildDir /classes/kotlin/js/main/${project.name} .js" )
72+ val into = File (" $buildDir /node_module/${project.name} .js" )
73+ into.createNewFile()
74+ into.writeText(from.readText()
75+ .replace(" require('firebase-" , " require('@gitlive/firebase-" )
76+ // .replace("require('kotlinx-serialization-kotlinx-serialization-runtime')", "require('@gitlive/kotlinx-serialization-runtime')")
77+ )
78+ }
79+ }
80+
81+ val copySourceMap by registering(Copy ::class ) {
82+ from(file(" $buildDir /classes/kotlin/js/main/${project.name} .js.map" ))
83+ into(file(" $buildDir /node_module" ))
84+ }
85+
86+
87+ val publishToNpm by creating(Exec ::class ) {
88+
89+ dependsOn(
90+ copyPackageJson,
91+ copyJS,
92+ copySourceMap,
93+ copyReadMe
94+ )
95+
96+ workingDir(" $buildDir /node_module" )
97+ // commandLine("npm", "publish")
98+ commandLine(" ls" )
99+ }
100+ }
101+
29102// tasks.withType<KotlinCompile<*>> {
30103// kotlinOptions.freeCompilerArgs += listOf(
31104// "-Xuse-experimental=kotlin.Experimental",
@@ -35,20 +108,84 @@ subprojects {
35108// }
36109
37110 afterEvaluate {
111+ // create the projects node_modules if they don't exist
112+ if (! File (" $buildDir /node_module" ).exists()) {
113+ mkdir(" $buildDir /node_module" )
114+ }
115+
116+ tasks.getByPath(" compileKotlinIos" ).dependsOn(rootProject.tasks.named(" unzipIOSFirebase" ))
117+ tasks.getByPath(" compileKotlinIosArm64" ).dependsOn(rootProject.tasks.named(" unzipIOSFirebase" ))
118+
38119 dependencies {
39120 " commonMainImplementation" (kotlin(" stdlib-common" ))
40121 " commonMainImplementation" (" org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.4" )
41122 " jsMainImplementation" (kotlin(" stdlib-js" ))
42123 " jsMainImplementation" (" org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.3.4" )
43124 " androidMainImplementation" (" org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.4" )
44125 " androidMainImplementation" (" org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.3.4" )
45- " jvmMainImplementation" (kotlin(" stdlib-jdk8" ))
46- " jvmMainImplementation" (" org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.4" )
47- " jvmMainApi" (" app.teamhub:firebase-java:0.3.1" )
48- " jvmMainApi" (" org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.3.4" )
49126 " iosMainImplementation" (" org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.4" )
50127 " iosMainImplementation" (" org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.4" )
51128 }
52129 }
130+
131+ apply (plugin= " maven-publish" )
132+ apply (plugin= " signing" )
133+
134+
135+ configure<PublishingExtension > {
136+
137+ repositories {
138+ maven {
139+ url = uri(" https://oss.sonatype.org/service/local/staging/deploy/maven2" )
140+ credentials {
141+ username = project.findProperty(" sonatypeUsername" ) as String? ? : System .getenv(" sonatypeUsername" )
142+ password = project.findProperty(" sonatypePassword" ) as String? ? : System .getenv(" sonatypePassword" )
143+ }
144+ }
145+ }
146+
147+ publications.all {
148+ this as MavenPublication
149+
150+ pom {
151+ name.set(" firebase-kotlin-sdk" )
152+ 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." )
153+ url.set(" https://github.com/GitLiveApp/firebase-kotlin-sdk" )
154+ inceptionYear.set(" 2019" )
155+
156+ scm {
157+ url.set(" https://github.com/GitLiveApp/firebase-kotlin-sdk" )
158+ connection.set(" scm:git:https://github.com/GitLiveApp/firebase-kotlin-sdk.git" )
159+ developerConnection.set(" scm:git:https://github.com/GitLiveApp/firebase-kotlin-sdk.git" )
160+ tag.set(" HEAD" )
161+ }
162+
163+ issueManagement {
164+ system.set(" GitHub Issues" )
165+ url.set(" https://github.com/GitLiveApp/firebase-kotlin-sdk/issues" )
166+ }
167+
168+ developers {
169+ developer {
170+ name.set(" Nicholas Bransby-Williams" )
171+ email.set(" nbransby@gmail.com" )
172+ }
173+ }
174+
175+ licenses {
176+ license {
177+ name.set(" The Apache Software License, Version 2.0" )
178+ url.set(" http://www.apache.org/licenses/LICENSE-2.0.txt" )
179+ distribution.set(" repo" )
180+ comments.set(" A business-friendly OSS license" )
181+ }
182+ }
183+
184+ }
185+ }
186+
187+
188+ }
189+
53190}
54191
0 commit comments