11import de.undercouch.gradle.tasks.download.Download
2+ import org.apache.tools.ant.taskdefs.condition.Os
23
34plugins {
45 kotlin(" multiplatform" ) version " 1.3.70" apply false
@@ -24,51 +25,69 @@ val minSdkVersion by extra(14)
2425
2526tasks {
2627 val downloadFirebaseZipFile by creating(Download ::class ) {
28+ onlyIfModified(true )
2729 src(" https://github.com/firebase/firebase-ios-sdk/releases/download/6.17.0/Firebase-6.17.0.zip" )
28- dest(File (rootDir , " Firebase-6.17.0.zip" ))
30+ dest(File (" $buildDir " , " Firebase-6.17.0.zip" ))
2931 overwrite(true )
32+
3033 }
3134
3235 val unzipFirebase by creating(Copy ::class ) {
3336 dependsOn(downloadFirebaseZipFile)
3437 from(zipTree(downloadFirebaseZipFile.dest))
35- into(rootDir)
38+ into(" $buildDir " )
39+ outputs.upToDateWhen { File (" $buildDir " ).exists() }
3640 }
3741
38- val copyIOSFirebaseAuth by creating(Copy ::class ){
42+ val copyIOSFirebaseAuthFramework by creating(Copy ::class ){
43+ doFirst {
44+ project.delete(files(" $rootDir /firebase-auth/src/iosMain/c_interop/modules/" ))
45+ }
3946 dependsOn(unzipFirebase)
40- from(" $rootDir /Firebase/FirebaseAuth/FirebaseAuth.framework" )
47+ from(" $rootDir /$buildDir / Firebase/FirebaseAuth/FirebaseAuth.framework" )
4148 into(" $rootDir /firebase-auth/src/iosMain/c_interop/modules/FirebaseAuth.framework" )
4249 }
4350
44- val copyIOSFirebaseDatabase by creating(Copy ::class ){
45- dependsOn(copyIOSFirebaseAuth)
46- from(" $rootDir /Firebase/FirebaseDatabase/FirebaseDatabase.framework" )
51+ val copyIOSFirebaseDatabaseFramework by creating(Copy ::class ){
52+ doFirst {
53+ project.delete(files(" $rootDir /firebase-database/src/iosMain/c_interop/modules/" ))
54+ }
55+ dependsOn(unzipFirebase)
56+ from(" $rootDir /$buildDir /Firebase/FirebaseDatabase/FirebaseDatabase.framework" )
4757 into(" $rootDir /firebase-database/src/iosMain/c_interop/modules/FirebaseDatabase.framework" )
4858 }
4959
50- val copyIOSFirebaseFirestore by creating(Copy ::class ){
51- dependsOn(copyIOSFirebaseDatabase)
52- from(" $rootDir /Firebase/FirebaseFirestore/FirebaseFirestore.framework" )
53- into(" $rootDir /firebase-database/src/iosMain/c_interop/modules/FirebaseFirestore.framework" )
60+ val copyIOSFirebaseFirestoreFramework by creating(Copy ::class ){
61+ doFirst {
62+ project.delete(files(" $rootDir /firebase-firestore/src/iosMain/c_interop/modules/" ))
63+ }
64+ dependsOn(unzipFirebase)
65+ from(" $rootDir /$buildDir /Firebase/FirebaseFirestore/FirebaseFirestore.framework" )
66+ into(" $rootDir /firebase-firestore/src/iosMain/c_interop/modules/FirebaseFirestore.framework" )
5467 }
5568
56- val copyIOSFirebaseFunctions by creating(Copy ::class ){
57- dependsOn(copyIOSFirebaseFirestore)
58- from(" $rootDir /Firebase/FirebaseFunctions/FirebaseFunctions.framework" )
59- into(" $rootDir /firebase-database/src/iosMain/c_interop/modules/FirebaseFunctions.framework" )
69+ val copyIOSFirebaseFunctionsFramework by creating(Copy ::class ){
70+ doFirst {
71+ project.delete(files(" $rootDir /firebase-functions/src/iosMain/c_interop/modules/" ))
72+ }
73+ dependsOn(unzipFirebase)
74+ from(" $rootDir /$buildDir /Firebase/FirebaseFunctions/FirebaseFunctions.framework" )
75+ into(" $rootDir /firebase-functions/src/iosMain/c_interop/modules/FirebaseFunctions.framework" )
6076 }
6177
62- val copyAllIOSFirebaseFrameworks by creating(Copy ::class ){
63- dependsOn(copyIOSFirebaseFunctions)
64- from(" $rootDir /Firebase/FirebaseAnalytics/FirebaseCore.framework" )
78+ val copyIOSFirebaseAppFramework by creating(Copy ::class ){
79+
80+ doFirst {
81+ project.delete(files(" $rootDir /firebase-app/src/iosMain/c_interop/modules/" ))
82+ }
83+
84+ dependsOn(unzipFirebase)
85+ from(" $rootDir /$buildDir /Firebase/FirebaseAnalytics/FirebaseCore.framework" )
6586 into(" $rootDir /firebase-app/src/iosMain/c_interop/modules/FirebaseCore.framework" )
6687 }
6788
6889}
6990
70-
71-
7291subprojects {
7392
7493
@@ -121,24 +140,14 @@ subprojects {
121140
122141
123142 val publishToNpm by creating(Exec ::class ) {
124-
125- if (! File (rootDir, " Firebase" ).exists()) {
126- dependsOn(
127- rootProject.tasks.named(" copyAllIOSFirebaseFrameworks" ).get(),
128- copyPackageJson,
129- copyJS,
130- copySourceMap,
131- copyReadMe
132- )
133- } else {
134- dependsOn(
135- copyPackageJson,
136- copyJS,
137- copySourceMap,
138- copyReadMe
139- )
140143
141- }
144+ dependsOn(
145+ copyPackageJson,
146+ copyJS,
147+ copySourceMap,
148+ copyReadMe
149+ )
150+
142151 workingDir(" $buildDir /node_module" )
143152 // commandLine("npm", "publish")
144153 commandLine(" ls" )
@@ -158,7 +167,7 @@ subprojects {
158167 if (! File (" $buildDir /node_module" ).exists()) {
159168 mkdir(" $buildDir /node_module" )
160169 }
161-
170+
162171 dependencies {
163172 " commonMainImplementation" (kotlin(" stdlib-common" ))
164173 " commonMainImplementation" (" org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.4" )
0 commit comments